Computer Science, asked by cheerladinnemouli123, 1 year ago

Write a C program to read and display different data type values. Sample Input and Output: Enter int, short int and long int values : 23456 212 43567184 Enter float, double and long double values : 3.21 4.5678 11.234567 Enter a character : A Given int value : 23456 Given short int value : 212 Given long int value : 43567184 Given float value : 3.210000 Given double value : 4.567800 Given long double value : 11.234567 Given character​

Answers

Answered by Raghav1330
25

Answer:

As explained in code.

Explanation:

Every data type in c has a format specifier that has to be Taken input through scanf. Scanf is a predefined function in c compiler which takes two parameters of arguments one the format specifier and other the variable. Now format specifier for int is %d for short is %d as well because both of these share same range till -32768 to 32767. For double is %lf and

long double is %Lf. For float is %f.

#include<stdio.h>

void main()

{

int a;

long b;

short c;

float d;

long double e;

printf("enter int") ;

scanf(%d, &a) ;

printf(a) ;

printf("enter short") ;

scanf(%d, &b) ;

printf(b) ;

printf("enter double") ;

scanf(%lf, &c) ;

printf(c) ;

printf("enter float") ;

scanf(%f, &d) ;

printf(d) ;

printf("enter long double") ;

scanf(%Lf, &e) ;

printf(e) ;

}

Similar questions