Variable [MCQ] : Find Output of Program (Multiple Choice Questions)
Question 16 |
What will be the output of the following code ?
int main() { int num,OS_Solaris,OS_Windows,OS_HP-UX; printf("Enter the number (1-3):\n"); scanf("%d",&num); switch(num) { case 1: OS_Solaris = 20; break; case 2: OS_Windows = 30; break; case 3: OS_HP-UX = 40; break; default: printf("Hmm! only 1-3 :-)\n"); break; } return 0; }Consider num entered is 3.
OS_HP-UX = 40will be executed. | |
Compile Error will make compilation unsuccessful, | |
Cannot Execute Switch Case Statement | |
None of these |
Question 16 Explanation:
Special Symbols are not allowed while declaring identifier.
Question 17 |
#include<stdio.h> int main(){ int M-PI=25; printf("%d",M_PI); return 0; }Find out error in the above code.
None of these | |
All Characters in the Variable should not be in Capital Case. | |
M-PI cannot be declared as it is One of the C Constant. | |
Variable Declaration is Illegal |
Question 17 Explanation:
Special Characters are not allowed.
Congratulations - you have completed C Programming : Multiple Choice Questions.
You scored %%SCORE%% out of %%TOTAL%%.
Your performance has been rated as %%RATING%%
Your answers are highlighted below.
Question 16 |
What will be the output of the following program ?
#include<stdio.h> void main() { int var1=10; { int var2 = 20; printf("%d %d",var1,var2); } printf("%d %d",var1,var2); }
10 20 10 20 | |
Run Time Error | |
10 20 10 garbage | |
Compile Time Error |
Question 16 Explanation:
Outer block can’t access variables declared inside Inner Block.
Question 17 |
Guess output of program -
#include<stdio.h> void main() { int var1=10; { int var1 = 20; printf("%d %d",var1,var1); } printf("%d %d",var1,var1); }
10 10 20 20 | |
20 10 20 10 | |
20 20 10 10 | |
10 20 10 20 |
Question 17 Explanation:
If same variable is declared inside inner as well as outer block then higher priority will be given to inner block.
Once you are finished, click the button below. Any items you have not completed will be marked incorrect.