-We use scanf() function to take a input from the user in console.
Syntax-
scanf("format specifier",&variable);
- Here format specifier is the type of the variable like %d,%f,%c etc.
- '&' is used in scanf(), without '&' it will give an error.
- variable is the object where we want to store our value.
program-
#include< stdio.h>
int main()
{
int a;
float b;
char c;
printf("Enter integer valuen");
scanf("%d",&a);
printf("Enter float valuen");
scanf("%f",&b);
printf("Enter any character n");
scanf("%s",&c);
printf("Your integer number is %d",a);
printf("Your float number is %f",b);
printf("Your character is %c",c);
}
Enter integer value
15
Enter float value
1.234
Enter any character
a
Your integer number is 15
Your float number is 1.234000
Your character is a