These
functions are used to provide input through console and display the output
console.
Input functions
1.      
scanf():- It can be used to provide numeric and non
numeric values to the variable as shown below.
                int a;
                float b; 
                char c;
                scanf(“%d%f%c”,&a,&b,&c);
header file is <stdio.h>
2.      
getchar():- It is used to read 1 character at a time
supplied through the keyboard.
                char c = getchar();
header file is <stdio.h>
3.      
gets():- This function is used to read a string (an array
of characters). It reads one line at a time.
                char name[80];
//array declaration
                gets(name);
header file is <stdio.h>
4.      
getch():- It reads a character from the screen with echo
off i.e. the character pressed is not displayed.
                char c = getch();
header file is <conio.h>
5.      
getche():- Like getch this function reads a character from
the screen but with echo on.
                char c = getche();
header file is <conio.h>
6.      
cin.get():- It is used to read one character or string from
the screen.
                  char c;
                  cin.get(c);
                  OR
                  char
set[80];
                  cin.get(st,80,‘\n’);
‘\n’ is delimiter and 80 is size of string to be read.
header file is <iostream>
7.      
cin.getline():- It is used to read a string from  the screen.
                  char set[80];
                  cin.getline(st,80,‘\n’);
or cin.getline(st,80);
header file is <iostream>
Output functions
1.      
printf():- It can be used to display numeric and non
numeric values to the variable as shown below.
                int a;
                float b; 
                char c;
                printf(“%d%f%c”,a,b,c);
header file is <stdio.h>
2.      
putchar():- It is used to display 1 character at a time.
                putchar(c);
header file is <stdio.h>
3.      
puts():- This function is used to display a string (an
array of characters).
                char name[80];
//array declaration
                puts(name);
header file is <stdio.h>
4.      
putch():- It displays a character from the screen with
echo off.
                putch(c);
header file is <conio.h>
5.      
putche():- Like putch this function displays a character on
the screen but with echo on.
                putche(c);
header file is <conio.h>
6.      
cout.get():- It is used to display one character or string on
the screen.
                  char c;
                  cout.put(c);
header file is <iostream>
7.      
cout.write():- This function can be used to display one or more
characters as specified by the type 
                  cout.write(st,80);
This can be used to display part of the string as specified by the size
n.
                  cout.write(st,n);
//it displays first n characters of string st.
header file is <iostream>
 
No comments:
Post a Comment