Write a program to input the value of different datatype and print them.
C Program
#include <stdio.h>int main(){char ch;int num;float floatNum;double doubleNum;long longNum;printf("Enter a charcter : ");ch = getchar();getchar();printf("Enter a integer number : ");scanf("%d", &num);printf("Enter a floating point number : ");scanf("%f", &floatNum);printf("Enter a double number : ");scanf("%lf", &doubleNum);printf("Enter a long number : ");scanf("%ld", &longNum);printf("\n\n");printf("Character is '%c' \n", ch);printf("Number is %d\n", num);printf("Floating point number is %f\n", floatNum);printf("Double number is %lf\n", doubleNum);printf("Long value is %ld\n", longNum);return 0;}
Input:
Enter a charcter : A
Enter a integer number : 12
Enter a floating point number : 225.6
Enter a double number : 2191892.454
Enter a long number : 21213131
Output:
Character is 'A'
Number is 12
Floating point number is 225.600006
Double number is 2191892.454000
Long value is 21213131
No comments:
Post a Comment