Tuesday 7 November 2017

Data Types Questions In C3


11. 

What is the output of this C code (on a 32-bit machine) ?

int main() 
{
 int x = 10000; 
double y = 56; 
int *p = &x; 
double *q = &y; 
printf("p and q are %d and %d", sizeof(p), sizeof(q));
 return 0; 
}

A. p and q are 4 and 4
B. p and q are 4 and 8
C. Compiler error
D. p and q are 2 and 8


Answer: A

Explanation:

Size of any type of pointer is 4 on a 32-bit machine. 

Output:
$ cc pgm6.c 
$ a.out 
p and q are 4 and 4

---------------------------------------------------------------------------------------------

12.

Which is correct with respect to size of the datatypes?

A. char > int > float
B. int > char > float
C. char < int < double
D. double > char > int

Answer: C

Explanation:

char has lesser bytes than int and int has lesser bytes than double in any system.

-------------------------------------------------------------------------------------------

13.

Which of the datatypes have size that is variable?

A. int
B. struct
C. float
D. double

Answer: B

Explanation:

Since the size of the structure depends on its fields, it has a variable size.

---------------------------------------------------------------------------------------------

14.

Predict the output

#include
int main()
{
float c = 5.0;
printf ("Temperature in Fahrenheit is %.2f", (9/5)*c + 32); 
return 0; 
}

A. Temperature in Fahrenheit is 41.00
B. Temperature in Fahrenheit is 37.00
C. Temperature in Fahrenheit is 0.00
D. Compiler Error

Answer: B

----------------------------------------------------------------------------------------

First                                                     Previous                      

---------------------------------------------------------------------------------------



More Imp Topics:






















    100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

    Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...