Table of Content

Variable Naming MCQ : True or False Questions (Multiple Choice)


Question 1
Guess the output of the following program ?
#include<stdio.h>
int main()
{
    int i = 10, j = -1, k = 0, w, x, y, z;
    w = i || j || k;
    x = i && j && k;
    y = i || j && k;
    z = i && j || k;
    printf("%d, %d, %d, %d\n", w, x, y, z);
    return 0;
}
A
1, 0, 1, 0
B
1, 1, 1, 1
C
1, 0, 0, 1
D
1, 0, 1, 1
Question 2
What will be the value of Z ?
#include<stdio.h>
int main()
{
    int x=100, y=10, z;
    z = x!=50 || y == 5;
    printf("z = %d\n", z);
    return 0;
}
A
2
B
0
C
1
D
Compile Error
Question 2 Explanation: 
z = x != 50 || y == 5;
  = True || y == 5;
  = True || False;
  = True
  = 1
Question 3
Guess the output of the following program ?
#include<stdio.h>
int main()
{
    int x = 10, y, z;
    y = ++x;
    z = x++;
    printf("%d, %d, %d\n", x, y, z);
    return 0;
}
A
12, 11, 10
B
12, 11, 11
C
12, 10, 10
D
12, 10, 11
Question 3 Explanation: 
y = ++x;  // Value of x is Incremented and then Assigned
z = x++;  // Value of x is Assigned and then Incremented
There are 3 questions to complete.