printf() is C's major output function that belongs to the standard input/output header file stdio.h. It refers to the standard output device (monitor) and can perform both formatted and unformatted output. Syntax includes text in double quotes followed by conversion characters/format specifiers and variables/expressions. It returns an int indicating the number of characters printed. Backslash characters are called escape sequences and are used to format output but are not displayed; they have special meanings like new line, tab, etc.
printf() is C's major output function that belongs to the standard input/output header file stdio.h. It refers to the standard output device (monitor) and can perform both formatted and unformatted output. Syntax includes text in double quotes followed by conversion characters/format specifiers and variables/expressions. It returns an int indicating the number of characters printed. Backslash characters are called escape sequences and are used to format output but are not displayed; they have special meanings like new line, tab, etc.
printf() is C's major output function that belongs to the standard input/output header file stdio.h. It refers to the standard output device (monitor) and can perform both formatted and unformatted output. Syntax includes text in double quotes followed by conversion characters/format specifiers and variables/expressions. It returns an int indicating the number of characters printed. Backslash characters are called escape sequences and are used to format output but are not displayed; they have special meanings like new line, tab, etc.
It belongs to standard input output header file [ stdio.h ]
It always refers standard output device i.e. monitor. In printf f means formatted. Syntax: int printf(“ [text] [conversion characters / format specifiers ] “ [ , variables ] [ , expressions ] ); Examples: Printf(“Hi”); Hi /* unformatted */ int a=10; float b=1.2; printf(“a=%d\n”,a); a=10 /* formatted */ printf(“b=%f”,b); b=1.200000 printf(“sum=%f”,a+b); printf(“a=%d, b=%f, sum=%f”,a,b,a+b); printf(“%d + %f = %f”,a,b,a+b); 10+1.2=11.2 printf(“%d”,a); 10 Note: 1. In printf() the first argument should be in “ “. 2. In printf execution order is right to left. 3. In printf everything printed as it is except conversion characters and back slash characters. 4. Printf always return int that indicates the no of characters printing on that screen. 5. Printf can perform both formatted and unformatted outputs. Eg. write a program to find the string length without using loop / strlen(). #include<stdio.h> #include<conio.h> #include<stdlib.h> main() { printf("Kishore"); getch(); system("cls"); printf("Vizag"); getch(); system("cls"); printf("India"); 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 ]