Input / Output in C

Console I/O functions can be further classified into two categories formatted and unformatted console I/O functions. The basic difference between them is that the formatted functions allow the input read from the keyboard or the output displayed on the VDU to be formatted as per our requirements.

printf: This function is used to display output to the output screen. The general syntax of this function is as follows
printf("format string",var_list);

int    	    %d %X %x %o %u %p
float       %f
double      %lf %Lf
char        %c
string	    %s	

Escape Sequence:
\n	New Line
\t	Tab
\b	Back Space
\f	Form Feed
\r	Carriage Return
\a	Alarm
\\	Back Slash
\" 	Double Quote

scanf: This function allows us to enter data from keyboard that will be formatted in a certain way. The general form of scanf( ) statement is as follows:
scanf("format string",var_address);


#include< stdio.h >
int main( ) {
 int  a, b;
 printf("Enter value a: ");
 scanf("%d", &a);
 printf("Enter value b: ");
 scanf("%d", &b);

 printf("User Input is:\n");
 printf("A=%d & B=%d", a, b);
 return 0;

Enter value a: 17
Enter value b: 23

User Input is:
A=17 & B=23

getchar: This function allows us to enter character from keyboard. The general form of getchar( ) statement is as follows:
char ch = getchar( );


#include< stdio.h >
int main( ) {
  char choice;
  printf("Enter Any Char: ");
  choice = getchar();
  printf("Input is: %c",choice); 
  return 0;

Enter Any Char: F
Input is: F

Next topic is Function in C


Training For College Campus

We offers college campus training for all streams like CS, IT, ECE, Mechanical, Civil etc. on different technologies like
C, C++, Data Structure, Core Java, Advance Java, Struts Framework, Hibernate, Python, Android, Big-Data, Ebedded & Robotics etc.

Please mail your requirement at

Projects For Students

Students can contact us for their projects on different technologies Core Java, Advance Java, Android etc.

Students can mail requirement at

(8AM to 10PM):

+91-8527238801 , +91-9451396824

© 2017,, All rights reserved