Вы находитесь на странице: 1из 3

Printf():Printf() is a output function.

Use to display output on screen.


How to use:
Syntax:
Printf(part 1 , part 2);
Part 1:
Part 1 consist of the following.
Text message
Escape sequences
Format specifiers
Text messages:
It may be any text message that we want to
display on screen.
e.g.
printf(have a good day);
printf(aaaaaaaaaaaaaaaaaaaaaaaaa);
printf(hv a ;;;;;;;;.//////god dy);

escape sequences:
these are the special symbol having specific
meanings for the system.
Escape sequences start with the symbol \.
e.g.
\n use for new line
\t use to give spaces.
Example:
Printf(have \n a\n bad day. \n today its a bit
hot);
it will print the text in two lines.
Printf(\t Name : \t\t CECOS);

Format specifier:
Format specifier always start with the
symbol % having specific meaning for the
system.
e.g.

%d for decimal number


%f for float number
%c for character data
%s for string data
Note : part1 must be in double quotes.
Part 2:
Part 2 consist of the following.
Variables
Constant
Expression

Expression:2 +2
e.g:
printf(addition of 2+2 is

%d , 2+2)

printf(value is %d , 123);
printf(percentage = %f ,89.5);
printf(subtraction is = %d,12+23)

Вам также может понравиться