datatypess


What will be output when you will execute following c code?

#include<stdio.h>
int main(){
    printf("%d\t",sizeof(6.5));
    printf("%d\t",sizeof(90000));
    printf("%d",sizeof('A'));
    return 0;
}

Choose all that apply:
(A) 4 2 1
(B)8 2 1 
(C)4 4 1
(D)8 4 1
(E)8 4 2


Explanation:

Turbo C++ 3.0: 8 4 2
Turbo C ++4.5: 8 4 2
Linux GCC:  8 4 4
Visual C++: 8 4 4

By default data type of numeric constants is:
6.5 :  double
90000: long int
‘A’: char
In C size of data type varies from compiler to compiler.
In TURBO C 3.0 (16 bit compilers) size of:
double is 8 byte
Long int is 4 byte
Character constant is 2 byte   (size of char data type is one byte)
In TURBO C 4.5 or Linux GCC compilers (32 bit compilers) size of:
double is 8 byte
long int is 8 byte
Character constant is 2 byte  

Comments

Popular posts from this blog

Area & volume

Algebra