0% found this document useful (0 votes)
15 views

29-7-23 Java Batch Printf Fun

printf() is a major predefined output function in C that is used for formatted and unformatted output. It takes a format string as the first argument, followed by additional arguments that correspond to format specifiers in the string. printf() returns the number of characters printed and sends output to the standard output device like a monitor. Backslash escape sequences in printf() format strings control formatting but are not printed as part of the output.

Uploaded by

Amol Shinde
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

29-7-23 Java Batch Printf Fun

printf() is a major predefined output function in C that is used for formatted and unformatted output. It takes a format string as the first argument, followed by additional arguments that correspond to format specifiers in the string. printf() returns the number of characters printed and sends output to the standard output device like a monitor. Backslash escape sequences in printf() format strings control formatting but are not printed as part of the output.

Uploaded by

Amol Shinde
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

printf(): It is the major predefined output function in C,

available in stdio.h  Standard Input Output Header file.


Printf always refers standard output device i.e. monitor.
Syntax:
int printf(“[text] [conversion characters/format
specifiers] “ [, variables ] [ , expressions ] );
Note:
1. Printf always return int that indicate the no of visible
/ printable characters in “ “.
2. In printf execution order right to left but printing is
left to right.
3. In printf the first argument should be in “ “.
4. In printf everything printed as it is except back slash
characters and conversion characters.
5. Printf can perform both formatted and unformatted
outputs.

Example: Write a C program to find string length


without using strlen() or a loop.
In Dev C++:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
main()
{
printf("Kishore Naidu");
getch();
system("cls");
printf("Vizag");
getch();
system("cls");
printf("Andhra Pradesh");
getch();
}
BACK SLASH / ESCAPE SEQUENCE CHARACTERS
They started with back slash [ \ ].
They used to format the outputs.
They participated in program execution but not
displayed in output. Hence they are also called
escape sequence characters.
Each back slash character=1 byte i.e. one character.
BACK SLASH CHARACTER DESCRIPTION
\a Alert [ beep sound ]
\b Back space
\n New line character
\t Tab space
\r Carriage return[beginning of
line]
\f
Form feed
\v Vertical tab
\0 Null char
\\ \ [ invalid ]
\k k [ invalid ]

You might also like