Formating Input/Output in C Language

Estudies4you

Formating Input/Output

printf() and scanf() functions:
printf() and scanf() functions are inbuilt library functions in C language which are available in C library by default. These functions are declared and defined in "stdio.h" which is a header file.

printf() function:
printf() function is used to print the "character, string, float, integer, octal and hexadecimal values" onto the output screen.
We use printf() function with the %d format specifier to display the value of an integer variable.
Similary %c is used to display character, %f for float variable, %s for string variable, %lf for double and %x for hexadecimal variable.
To generate a newline, we use"\n" in C printf() statement.

scanf() function:
scanf() function is used to read character, string, numeric data from the keyboard
Consider the program example given below, where the user enters a character:
Then, the user enters a string and this value is assigned to the variable "str" and then displayed.
Example:
{
char ch;
char str[100];
printf("Enter anyt character \n");
scanf("%c",&ch);
}
Note: All functions in C, are case sensitive.

Format Specifiers:
The "Format Specifier" is the sequence passed as the formatting string argument. 
Format Specifier used by scanf and printf
Computing Environments in c language, Computing Environments in c programming, c programming notes unitwise, c programming preparative notes unit wise, c programming notes topic wise, c programming notes download free, c programming notes free download, c programming notes pdf,free download c programming notes, c language notes download free,estudies, estudies4you,JNTUH R16 Computer Programming in  C Syllabus,jntuh Computer Programming in  C study material for civil,r16 Computer Programming in  C study material,Computer Programming in  C lecture notes,Computer Programming in  C course file,Computer Programming in  C co po mapping,Computer Programming in  C course outcome,Computer Programming in  C course overview,Computer Programming in  C unitwise notes pdf,Computer Programming in  C for engineering,jntuh Computer Programming in  C class room notes pdf,Computer Programming in  C previous question papers pdf,Computer Programming in  C notes with real time examples, jntuh cpds lecture notes pdf,jntuh c language notes pdf,jntu c language study material, c programming notes pdf,c programming lecture notes pdf, c programming study material pdf,c programming previous question papers pdf

The size and range of these data types may vary among processor types and compilers.
Data type qualifiers modify the behavior of variable type to which they are applied.
Data type qualifiers can be classified into two types:
Size Qualifiers
Sign Qualifiers

Size Qualifiers:
Size Qualifiers alter the size of the basic data types. There are two size qualifiers that can be applied to integers: short and long.
The minimum size of "short int" is 16 bit.
The size of 'int' must be greater than or equal to that of 'short int'. The size of 'long int' must be greater than or equal to a 'short int'. The minimum size of 'long int' is 32 bits.

Signed Qualifiers:
The keywords signed and unsigned are the two sign qualifiers that specify whether a variable can hold both the negative and positive numbers, or only positive numbers. These qualifiers can be applied to the data types int and char only.
Example: unsigned int i;


To Top