This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Relational & Logical Operators – 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()
{
int x = 1, y = 0, z = 5;
int a = x && y || z++;
printf("%d", z);
}
a) 6
b) 5
c) 0
d) Varies
View Answer
Explanation: None.
2. What will be the output of the following C code?
#include <stdio.h>
void main()
{
int x = 1, y = 0, z = 5;
int a = x && y && z++;
printf("%d", z);
}
a) 6
b) 5
c) 0
d) Varies
View Answer
Explanation: None.
3. What will be the output of the following C code?
#include <stdio.h>
int main()
{
int x = 1, y = 0, z = 3;
x > y ? printf("%d", z) : return z;
}
a) 3
b) 1
c) Compile time error
d) Run time error
View Answer
Explanation: None.
4. What will be the output of the following C code?
#include <stdio.h>
void main()
{
int x = 1, z = 3;
int y = x << 3;
printf(" %d\n", y);
}
a) -2147483648
b) -1
c) Run time error
d) 8
View Answer
Explanation: None.
5. What will be the output of the following C code?
#include <stdio.h>
void main()
{
int x = 0, y = 2, z = 3;
int a = x & y | z;
printf("%d", a);
}
a) 3
b) 0
c) 2
d) Run time error
View Answer
Explanation: None.
6. What will be the final value of j in the following C code?
#include <stdio.h>
int main()
{
int i = 0, j = 0;
if (i && (j = i + 10))
//do something
;
}
a) 0
b) 10
c) Depends on the compiler
d) Depends on language standard
View Answer
Explanation: None.
7. What will be the final value of j in the following C code?
#include <stdio.h>
int main()
{
int i = 10, j = 0;
if (i || (j = i + 10))
//do something
;
}
a) 0
b) 20
c) Compile time error
d) Depends on language standard
View Answer
Explanation: None.
8. What will be the output of the following C code?
#include <stdio.h>
int main()
{
int i = 1;
if (i++ && (i == 1))
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.
- Apply for Computer Science Internship
- Apply for C Internship
- Check Computer Science Books
- Practice BCA MCQs
- Watch Advanced C Programming Videos