QUESTION DESCRIPTION :
Write a program to produce correct size of various data types on your computer
TEST CASE 1
INPUT
0
OUTPUT
Size of char:1
Size of int:4
Size of short int:2
Size of long int:8
Size of float:4
Size of double:8
EXPLANATION :
ALGORITHM :
Write a program to produce correct size of various data types on your computer
TEST CASE 1
INPUT
0
OUTPUT
Size of char:1
Size of int:4
Size of short int:2
Size of long int:8
Size of float:4
Size of double:8
EXPLANATION :
The problem requires you to print the exact size of the different data-types used in C. There are two methods of doing this , either print the size directly or use the sizeof() ( The sizeof() function ) function to print the exact size of the variable given in arguments.
ALGORITHM :
- To directly print the exact size just use the print statement and put whatever is required to it.
- Declare a variable of each type ( char , int , short , long , float , double )
- Use the sizeof() to get the size of each datatype ( sizeof( variable ) )
- Print the long unsigned integer value ( Different Datatypes in C ) received from the sizeof() function with the exact output message ( %ld )
No comments:
Post a Comment