Accepting Variables value from user

, by Prashant Gunjal

scanf ()
scanf function is use to read value entered by user.It uses %d %f and %c to accept integer float character values sequentially. '&' is require to read value in variable .

Screenshot :




code :

#include<stdio.h>
#include<conio.h>

void main()
{
int i_no;
float f_no;
char cha;
clrscr();
printf("\n\tEnter Integer Number = ");
scanf("%d",&i_no);
printf("\n\tEnter Float Number = ");
scanf("%f",&f_no);
printf("\n\tEnter Character = ");
flushall();
scanf("%c",&cha);

printf("\n\t\t****You Entered ****");
printf("\n\tInteger Number = %d ",i_no);
printf("\n\tFloat Number = %f",f_no);
printf("\n\tCharacter = %c",cha);
getch();
}

flushall() :
above function is use to clear cache memory before accepting char variable value

Output :

0 comments: