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.

C Programming Tokens:

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);

TYPE FORMATTERS:
DATA_TYPE  FORMATTER
------------------------
int    	    %d %X %x %o %u %p
float       %f
double      %lf %Lf
char        %c
string	    %s	

Escape Sequence:
SEQ	DETAIL
------------------------
\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);

Example:

#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;
}

  
OUTPUT
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( );

Example:

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

  
OUTPUT
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 info@prowessapps.in


Projects For Students

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

Students can mail requirement at info@prowessapps.in


CONTACT DETAILS

info@prowessapps.in
(8AM to 10PM):

+91-9026070669 , +91-9451396824

© 2016, prowessapps.in, All rights reserved