This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Type Conversions – 1”.
Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.
1. What will be the output of the following C code?
#include <stdio.h>
void main()
{
float x = 0.1;
if (x == 0.1)
printf("Sanfoundry");
else
printf("Advanced C Classes");
}
a) Advanced C Classes
b) Sanfoundry
c) Run time error
d) Compile time error
View Answer
Explanation: None.
2. What will be the output of the following C code?
#include <stdio.h>
void main()
{
float x = 0.1;
printf("%d, ", x);
printf("%f", x);
}
a) 0.100000, junk value
b) Junk value, 0.100000
c) 0, 0.100000
d) 0, 0.999999
View Answer
Explanation: None.
3. What will be the output of the following C code? (Initial values: x= 7, y = 8)
#include <stdio.h>
void main()
{
float x;
int y;
printf("enter two numbers \n");
scanf("%f %f", &x, &y);
printf("%f, %d", x, y);
}
a) 7.000000, 7
b) Run time error
c) 7.000000, junk
d) Varies
View Answer
Explanation: None.
4. What will be the output of the following C code?
#include <stdio.h>
void main()
{
double x = 123828749.66;
int y = x;
printf("%d\n", y);
printf("%lf\n", y);
}
a) 0, 0.0
b) 123828749, 123828749.66
c) 12382874, 12382874.0
d) 123828749, 0.000000
View Answer
Explanation: None.
5. What will be the output of the following C code?
#include <stdio.h>
void main()
{
int x = 97;
char y = x;
printf("%c\n", y);
}
a) a
b) b
c) 97
d) Run time error
View Answer
Explanation: None.
6. When double is converted to float, then the value is?
a) Truncated
b) Rounded
c) Depends on the compiler
d) Depends on the standard
View Answer
Explanation: None.
7. What will be the output of the following C code?
#include <stdio.h>
int main()
{
unsigned int i = 23;
signed char c = -23;
if (i > c)
printf("Yes\n");
else if (i < c)
printf("No\n");
}
a) Yes
b) No
c) Depends on the compiler
d) Depends on the operating system
View Answer
Explanation: None.
8. What will be the output of the following C code?
#include <stdio.h>
int main()
{
int i = 23;
char c = -23;
if (i < c)
printf("Yes\n");
else
printf("No\n");
}
a) Yes
b) No
c) Depends on the compiler
d) Depends on the standard
View Answer
Explanation: None.
Sanfoundry Global Education & Learning Series – C Programming Language.
To practice all areas of C language, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Check Computer Science Books
- Apply for Computer Science Internship
- Watch Advanced C Programming Videos
- Practice Computer Science MCQs
- Check C Books