Getch()
Getch () is a way to get a user inputted character.It can be used to hold program execution, but the ‘holding’ is simply a side-effect of its primary purpose which is to wait until the user enters a character.
getch();
Example of getch()
#include<stdio.h>
#include<conio.h>
void main(){
char c;
clrscr();
c=getch();
printf("C=%c",c);
getch();
}
Output
press a output is c=a
Getche()
Like getch() this is also non-standard function present in coini.h. It reads a single character from the keyword and display immediately on output screen without waiting for enter key.
Example of getche()
#include<stdio.h>
#include<conio.h>
void main(){
char c;
clrscr();
c=getche();
printf("\nC=%c",c);
getch();
}
Output
b
C=b
Getchar()
It read from
standard input. It is not display immediately on output screen waiting for
enter key.
Example of getchar()
#include<stdio.h>
#include<conio.h>
void main(){
char c;
clrscr();
c=getchar();
printf("C=%c",c);
getch();
}
Output
k -> enter
C=k
Enum
enum is a user defined data type in c.It is
mainly used to assign names to integral constants, the names make a program
easy to read and maintain.The keyword ‘enum’ is used to declare new enumeration
types in c and c++.
Enum day;
Example of enum
#include<stdio.h>
#include<conio.h>
enum OS{
mac=11,solaris=22,linux,kali,ubuntu,andriod
};
void main(){
clrscr();
printf("Mac=%d",mac);
printf("\nSolaris=%d",solaris);
printf("\nLinux=%d",linux);
printf("\nKali=%d",kali);
printf("\nUbuntu=%d",ubuntu);
printf("\nAndriod=%d",andriod);
getch();
}
Output
Mac=11
Solaris=22
Linux=23
Kali=24
Ubuntu=25
Andriod=26
0 Comments