C Program to Read Data From Keyboard
Write C Program to Read Data from Keyboard
#include<stdio.h>
int main()
{
int a;
float b;
char c;
//display message to console
printf("Enter the Decimal Number :--> ");
scanf("%d", &a); //Read from keyboard
printf("Enter the Floating Point Number :--> ");
scanf("%f", &b); //Read from keyboard
printf("Enter the Character :--> ");
scanf(" %c", &c); // Read from keyboard
//display values stored in the variable
printf("\nThe Decimal Number is : %d ",a);
printf("\nThe Floating Point Number is : %f ",b);
printf("\nThe Character is : %c ",c);
return 0;
}
Output:
Enter the Decimal Number :--> 89
Enter the Floating Point Number :--> 65.69
Enter the Character :--> r
The Decimal Number is : 89
The Floating Point Number is : 65.690002
The Character is : r