C Programming MCQ - Constant Variables & Data Types

51:  

What is the correct way to round offx, a float, to an int value?

A.

y=(int)(x+0.5)

B.

y=int(x+0.5)

C.

y=(int)x+0.5

D.

y=(int)(int)x+0.5)

 
 

Option: A

Explanation :

Click on Discuss to view users comments.

Write your comments here:



52:  

By default, any real number in 'C' is treated as

A.

A float

B.

A double

C.

A long double

D.

Depend upon memory model that you are using

 
 

Option: B

Explanation :

Click on Discuss to view users comments.

Write your comments here:



53:  

To print out a and b given below, which printf() statement would you use?

float a = 3.14;
double b = 3.14;

A.

printf("%f%f",a,b);

B.

printf("%Lf%f",a,b);

C.

printf("%Lf%Lf",a,b);

D.

printf("%f%Lf",a,b);

 
 

Option: A

Explanation :

Click on Discuss to view users comments.

Write your comments here:



54:  

When a variable of data type double is converted into float, then

A.

Rounding takes place

B.

Truncation takes place

C.

The lower order bits are dropped

D.

None of these

 
 

Option: A

Explanation :

Click on Discuss to view users comments.

Write your comments here:



55:  

The library function sqrt operates on a double precision argument. If, i is an integer variable, then which of the following calls would correctly compute sqrt(i)?

A.

sqrt((double)i)

B.

(double)sqrt(i)?

C.

(double)(sqrt(i))

D.

sqrt(i)

 
 

Option: A

Explanation :

Click on Discuss to view users comments.

Write your comments here: