#include void main() { int x = 5; if (x < 1) printf("hello"); if (x == 5) printf("hi"); else printf("no"); }
hi
hello
no
error
What will be the output of the following C code?
#include int x; void main() { if (x) printf("hi"); else printf("how are u"); }
hi
how are you
compile time error
error
What will be the output of the following C code?
#include void main() { int x = 0; if (x == 0) printf("hi"); else printf("how are u"); printf("hello"); }
hi
how are you
hello
hihello
What will be the output of the following C code?
#include void main() { int x = 5; if (x < 1); printf("Hello");
}
Nothing
Runtime error
Hello
Varies
What will be the output of the following C code? (Assuming that we have entered the value 1 in the standard input)
#include void main() { double ch; printf("enter a value between 1 to 2:"); scanf("%lf", &ch); switch (ch) { case 1: printf("1"); break; case 2: printf("2"); break; } }
Compile time error
1
2
Varies
What will be the output of the following C code? (Assuming that we have entered the value 1 in the standard input)
#include void main() { char *ch; printf("enter a value between 1 to 3:"); scanf("%s", ch); switch (ch) { case "1": printf("1"); break; case "2": printf("2"); break; } }
1
2
Compile time error
No Compile time error
What will be the output of the following C code? (Assuming that we have entered the value 2 in the standard input)
#include void main() { int ch; printf("enter a value between 1 to 2:"); scanf("%d", &ch); switch (ch) { case 1: printf("1\n"); break; printf("Hi"); default: printf("2\n"); } }
1
Hi 2
Run time error
2
What will be the output of the following C code? (Assuming that we have entered the value 1 in the standard input)
#include void main() { int ch; printf("enter a value between 1 to 2:"); scanf("%d", &ch); switch (ch, ch + 1) { case 1: printf("1\n"); break; case 2: printf("2"); break; } }
1
2
3
Runtime error
What will be the output of the following C code?
#include int main() { int x = 0; if (x++) printf("true\n"); else if (x == 1) printf("false\n"); }
true
false
compile ti,e error
undefined behaviour
The C statement “”if (a == 1 || b == 2) {}”” can be re-written as ___________
if (a == 1) if (b == 2){}
if (a == 1){} if (b == 2){}
if (a == 1){} else if (b == 2){}
none of the mentioned
What will be the output of the following C code? (Assuming that we have entered the value 1 in the standard input) #include void main() { double ch; printf("enter a value between 1 to 2:"); scanf("%lf", &ch); switch (ch) { case 1: printf("1"); break; case 2: printf("2"); break; } }
Compile time error
1
2
Varies
What will be the output of the following C code? (Assuming that we have entered the value 1 in the standard input)
#include void main() { char *ch; printf("enter a value between 1 to 3:"); scanf("%s", ch); switch (ch) { case "1": printf("1"); break; case "2": printf("2"); break; } }
1
compile time error
2
run time error
What will be the output of the following C code? (Assuming that we have entered the value 1 in the standard input)
#include void main() { int ch; printf("enter a value between 1 to 2:"); scanf("%d", &ch); switch (ch) { case 1: printf("1\n"); default: printf("2\n"); } }
1
2
1 2
Runtime error
What will be the output of the following C code? (Assuming that we have entered the value 1 in the standard input)
#include void main() { int ch; printf("enter a value between 1 to 2:"); scanf("%d", &ch); switch (ch, ch + 1) { case 1: printf("1\n"); break; case 2: printf("2"); break; } }
1
2
3
Runtime error
What will be the output of the following C code? #include int main() { int a = 1, b = 1; switch (a) { case a*b: printf("yes "); case a-b: printf("no\n"); break; } }
yes
no
Compile time error
yes no
What will be the output of the following C code?
#include int main() { int x = 97; switch (x) { case 'a': printf("yes "); break; case 97: printf("no\n"); break; } }
yes
yes no
Duplicate case value error
Character case value error
What will be the output of the following C code?
#include int main() { float f = 1; switch (f) { case 1.0: printf("yes\n"); break; default: printf("default\n"); } }
yes
yes default
Undefined behaviour
Compile time error
What will be the output of the following C code?
#include #define max(a) a int main() { int x = 1; switch (x) { case max(2): printf("yes\n"); case max(1): printf("no\n"); break; } }
yes no
yes
no
Compile time error
What will be the output of the following C code?
#include int main() { switch (printf("Do")) { case 1: printf("First\n"); break; case 2: printf("Second\n"); break; default: printf("Default\n"); break; } }