Data Types
- What will be the output of the following C code?
#include <stdio.h>
int main()
{
int num[4] = {11, 12, 13, 14, 15};
int k;
for (k = 0; k < 4; k++)
if ((char)num[k] == '14')
{
printf("%d\n", num[k]);
}
else
{
printf("False\n");
}
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
The char type-casted integral value 14 is 14 only.
- What will be the output of the following C code?
#include
printf("%.0f", 4.89);
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
5
- Which of the following is the correct output for the program given below?
#include <stdio.h>
int main ( )
{
float floatvalue = 8.25;
printf ("%d\n " , (int) floatvalue);
return 0;
}
-
View Hint View Answer Discuss in Forum
It prints '8'. because, we typecast the (int)floatvalue into integer. It converts the float value to the nearest integer value.
Correct Option: D
It prints '8'. because, we typecast the (int)floatvalue into integer. It converts the float value to the nearest integer value.
- Which of the following is valid range of long double ?
-
View Hint View Answer Discuss in Forum
1.7E-308 to 1.7E+308
Correct Option: D
1.7E-308 to 1.7E+308
- Which of the following is the correct datatype for the variable n in the statement given below?
n = 35.29 ;
-
View Hint View Answer Discuss in Forum
The 'float' is pretty enough to hold the data 23.45.
Correct Option: A
The 'float' is pretty enough to hold the data 23.45.