### Find Output Of Program

Question 1 :

What will be the output of the program?

``````#include
int main()
{
float a=0.7;
if(a < 0.7)
printf("C\n");
else
printf("C++\n");
return 0;
}``````

A). C
B). C++
C). Compiler error
D). Non of above

Explanation :

if(a < 0.7) here a is a float variable and 0.7 is a double constant. The float variable a is less than double constant 0.7. Hence the if condition is satisfied and it prints 'C'

Example:

``````#include
int main()
{
float a=0.7;
printf("%.10f %.10f\n",0.7, a);
return 0;
}``````

Output: 0.7000000000 0.6999999881

Question 2 :

What will be the output of the program?

``````#include
int main()
{
float *p;
printf("%d\n", sizeof(p));
return 0;
}``````

A). 2 in 16bit compiler, 4 in 32bit compiler
B). 4 in 16bit compiler, 2 in 32bit compiler
C). 4 in 16bit compiler, 4 in 32bit compiler
D). 2 in 16bit compiler, 2 in 32bit compiler

Explanation :

sizeof(x) returns the size of x in bytes.
float *p is a pointer to a float.

In 16 bit compiler, the pointer size is always 2 bytes.
In 32 bit compiler, the pointer size is always 4 bytes.

Question 3 :

What will be the output of the program?

``````#include
int main()
{
float fval=7.29;
printf("%d\n", (int)fval);
return 0;
}``````

A). 0
B). 0.0
C). 7.0
D). 7

Explanation :

printf("%d\n", (int)fval); It prints '7'. because, we typecast the (int)fval in to integer. It converts the float value to the nearest integer value.

Question 4 :

What will be the output of the program?

``````#include
#include
int main()
{
printf("%f\n", sqrt(36.0));
return 0;
}``````

A). 6.0
B). 6
C). 6.000000

Explanation :

printf("%f\n", sqrt(36.0)); It prints the square root of 36 in the float format(i.e 6.000000).

Declaration Syntax: double sqrt(double x) calculates and return the positive square root of the given number.

Question 5 :

What will be the output of the program?

``````#include
#include
int main()
{
printf("%d, %d, %d\n", sizeof(3.14f), sizeof(3.14), sizeof(3.14l));
return 0;
}``````

A). 4, 4, 4
B). 4, 8, 8
C). 4, 8, 10
D). 4, 8, 12