Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

C Chapter 3

Q. How many type of I/O function in C ? Draw the chart.

Ans:- Here is a picture explain the common I/O function in C.
Q.Explain the Working of getchar(), getche(), getch(),putch() and putchar() function in c.

Ans:- getchar() is a character input function which accept a single character as an input from console/standard input device e.g. Keyboard. It move the value to variable and forward the process after pressing the Enter(Carriage Return) Key. 
getchar() function belongs from "stdio.h".
e.g.

#include<stdio.h>
#include<conio.h>
void main()
{
char ch;
clrscr();
printf("Enter any character = ");
ch=getchar();
printf("\nInput is %c",ch);
}

getche() is also an character input function but when we press any key it assign the value to variable and move the process forward without waiting of any key or Enter(Carriage Return) Key.
getche() function belongs from "conio.h".
e.g.

#include<stdio.h>
#include<conio.h>
void main()
{
char ch;
clrscr();
printf("Enter any character = ");
ch=getche();
printf("\nInput is %c",ch);
}


getch() is also an character input function which hide the input. When we press any key it assign the value to variable and move the process forward without waiting of any key or Enter (Carriage Return) Key.
getche() function belongs from "conio.h".
e.g.
#include<stdio.h>
#include<conio.h>
void main()
{
char ch;
clrscr();
printf("Enter any character = ");
ch=getche();
printf("\nInput is %c",ch);
}

putch() and putchar() are character output function.
e.g.

#include<stdio.h>
#include<conio.h>
void main()
{
char ch='z';
clrscr();
putch(ch);
putchar('s');
}

No comments:

Post a Comment