C getch() function

C getch() function:

  • By using this function, we can read a char directly from the keyboard and until we are passing the char.
  • Generally getch() are placing at end of program after printing the output to stay the console position until we are passing the char.

Syntax:

getch();

Example:

void main()
{

int a,b,c,d,max;
printf(“Enter 4 values:”);
scanf(“%d%d%d%d%d”,&a,&b,&c,&d);
if(a>b&&a>c&&A>d)
{
max=a;
}
else
{
if(b>c&&b>d)
{
max=b;
}
else
{if(c>d)
max=c;
else max=d;
}
}
printf(“Maximum value:”,%d,max);
getch();
}

Powered by k2schools