While we need to enter value by the user or keyboard in c programming than we need to use scanf function. Which get the input from the user and store it in the variable. It is general input function of c programming. scanf function is used to provide the interactive feature to program which make program user friendly. General format of scanf function as below.
Syntax:
scanf("%d",&<variable name>); // To enter integer value by user.
scanf("%f",&<variable name>); // To enter float value by user.
Note:
Here must write & before the variable in scanf(); because if you not write &<variable name> than it store garbage value in variable.
Source Code
#include<stdio.h>
void main()
{
int no;
clrscr();
printf("Enter number::");
scanf("%d",&no);
printf("Number enter by you is:: %d",no);
getch();
}
void main()
{
int no;
clrscr();
printf("Enter number::");
scanf("%d",&no);
printf("Number enter by you is:: %d",no);
getch();
}
Download |
---|
0 comments:
Post a Comment