You are on page 1of 8

printf():

It is the major output function in c language.


It is a predefined function available in stdio.h –
standard input output header file.
Printf always refers standard output device i.e. monitor.
In printf f means formatted.
Syntax:
int printf(“ [ text ] [ conversion characters / format
specifires ] “ [ , variables ] [ , expressions ] );
Note:
1. Printf always return int that indicates the no of
characters in “ “.
2. In printf the first argument should be in ” “.
3. In printf execution order is right to left but printing
is left to right.
4. In printf everything printed as it is except
conversion characters and back slash characters.
5. Printf can perform both formatted and
unformatted outputs.
Eg. Write a program to find no of characters in given
string without using loop / strlen().
Eg: kishore is 7 letters string
Examples of printf:
printf(“Hi”);  Hi
int a=10;
float b=1.2;
printf(“a=”);  a=
printf(“a=%d”,a);  a=10
printf(“b=%f”,b); b=1.200000
printf(“a=%d b=%f”,a,b); a=10 b=1.200000
printf(“Sum=%f”, a+b);  11.200000
printf(“a=%d, b=%f, sum=%f”,a,b,a+b);
printf(“%d + %f = %f”,a,b,a+b);
Alt+f select New for new file
F3 for old files
Alt+f3 for closing the current file or click on green box.
To close all files at a time alt+w  select close all.
F5 – full blue screen
F6 for moving between windows.
Alt+x – Close the c++.
Alt+w and select tile / cascade for all files display

You might also like