C program to take inputs from the user
ADVERTISEMENTS
C program to take inputs from the user. There are you will learn how to take inputs from the user in the C language.
Let us understand this example through the C program:
// C program to take inputs from the user
#include <stdio.h>
int main() {
int p;
float q;
char r[100];
printf("Enter the integer value::\n");
scanf("%d", &p);
printf("Enter the float value::\n");
scanf("%f", &q);
printf("Enter the string value::\n");
scanf("%s", r);
printf("\nThe integer input is:\n%d\n", p);
printf("\nThe float input is:\n%f\n", q);
printf("\nThe string input is:\n%s\n", r);
return 0;
}
Output:
Enter the integer value::
5
Enter the float value::
7.5
Enter the string value::
hello
The integer input is:
5
The float input is:
7.500000
The string input is:
hello