Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

KLU- CLUSTER -6 DAY-5

Total questions: 30

Worksheet time: 30mins

Name
Class
Date
1.
#include<stdio.h> int main() { struct num { int i, j, k, l; }; struct num n = {1, 2, 3}; printf("%d %d %d %d", i, j, k, l); }
a)
1 2 3 0
b)
1 2 3 4
c)
1 2 3 garbage value
d)
Compilation Error
2.
#include<stdio.h> int main() { int i = 2; enum numbers{num1 = i, num2 , num3}n; printf("%d %d %d\n", num1, num2, num3); }
a)
Compilation Error
b)
2 3 4
c)
1 2 3
d)
None of the above
3.
#include<stdio.h> #define int char void main() { int i = 65; printf("sizeof(i)=%d", sizeof(i)); }
a)
sizeof(i)=2
b)
sizeof(i)=1
c)
Compiler Error
d)
None of These
4.
#include<stdio.h> #define x 2 int main() { int i; i = x*x*x; printf("%d",i); return 0; }
a)
8
b)
x is not declared
c)
No output
d)
Garbage value
5.
#include<stdio.h> #define square(x) x*x int main() { int i; i = 64/square(4); printf("%d",i); return 0; }
a)
16
b)
Compilation error
c)
4
d)
64
6.
#include<stdio.h> #define i 10 int main() { #define i 20 printf("%d",i); return 0; }
a)
Compilation error
b)
20
c)
10
d)
Runtime error
7.
#include<stdio.h> #define clrscr() 50 int main() { clrscr(); printf("%d\n",clrscr()); return 0; }
a)
Compilation error
b)
Runtime error
c)
50
d)
none of the above
8.
#include<stdio.h> 50; int main() { printf("%d\n",50); return 0; }
a)
Runtime Error
b)
Garbage value
c)
Compilation error
d)
50
9.
#include<stdio.h> int main(){ printf("%p",main); return 0; }
a)
Address
b)
Compilation error
c)
Garbage value
d)
Runtime error
10.
#include<stdio.h> #define x 10 int main() { printf("%d", x); return 0; }
a)
Garbage value
b)
Runtime error
c)
10
d)
Compilation error
11.
#include<stdio.h> enum colors {apple, orange, mango}; int main() { printf("%d %d %d", mango, apple, orange); return 0; }
a)
3 1 2
b)
2 0 1
c)
0 1 2
d)
1 0 2
12.
#include<stdio.h> #define CONDITION(i) printf("preprocessor\n"); int main() { CONDITION(0); return 0; }
a)
preprocessor
b)
Runtime error
c)
Compilation error
d)
none of the above
13.
#include<stdio.h> #define CONDITION(i)\ printf("preprocessor works\n"); int main() { CONDITION(0); return 0; }
a)
Runtime Error
b)
Compilation error
c)
preprocessor works
d)
None of the above
14.
#include<stdio.h> # define loop while(true) int main() { loop; printf("preprocessor-aptitude"); return 0; }
a)
program never ends
b)
Compilation error
c)
preprocessor-aptitude
d)
none of the above
15.
#include<stdio.h> # define x - -5 int main() { printf("%d",x); return 0; }
a)
Compilation error
b)
-
c)
-5
d)
5
16.
#include<stdio.h> # define x --5 int main() { printf("%d",x); return 0; }
a)
-
b)
Compilation error
c)
5
d)
-5
17.
#include<stdio.h> #define sqr(x) ++x * ++x int main() { int a = 3, z; z = ++a * ++a; a -= 3; printf("%d %d", sqr(a), z); return 0; }
a)
25 16
b)
16 16
c)
16 25
d)
25 25
18.
#include<stdio.h> #define x 1+2 int main() { int i; i = x * x * x; printf("%d",i); }
a)
27
b)
13
c)
7
d)
None of the one
19.
#include<stdio.h> #define a = int main() { int num a 6; printf("%d",num); return 0; }
a)
6
b)
Compilation error
c)
Garbage value
d)
Runtime error
20.
Time complexity of the code? int fun(int n, int m, int o) { if (n <= 0) printf("%d, %d\n",m, o); else { fun(n-1, m+1, o); fun(n-1, m, o+1); }
a)
Quadratic
b)
O (log n)
c)
O (n log m)
d)
Exponential
21.
#include<stdio.h> int main() { char DATE[15] = "Current Date"; printf("%s\n", __DATE__ ); return 0; }
a)
Current Date
b)
Sep 11 2023
c)
2023-09-11 00:00:00
d)
2023-09-11 00:00:00
22.
What will the following code output? #include<stdio.h> int main() { char TIME[15] = "Watch"; printf("%s\n",__TIME__); return 0; }
a)
Time in MM:HH:SS format
b)
Time in SS:MM:HH format
c)
Time in HH:MM:SS format
d)
Watch
23.
#include<stdio.h> int main() { printf("%d\n", __LINE__ ); return 0; }
a)
3
b)
6
c)
Compilation error
d)
4
24.
#include<stdio.h> #define preprocessor_works(x, y) \ printf(#x " and " #y " are great!\n") int main(void) { preprocessor_works(you, me); return 0; }
a)
you and me are great!
b)
#you and #me are great!
c)
No output
d)
Compilation error
25.
#include<stdio.h> # define puts "%s C preprocessor" int main() { printf(puts, puts); return 0; }
a)
Runtime error
b)
Compilation error
c)
%s C preprocessor %s C preprocessor
d)
%s C preprocessor C preprocessor
26.
#include<stdio.h> #define preprocessor(n) printf ("macro" #n " = %d", macro##n) int main(void) { int macro25 = 47; preprocessor(25); return 0; }
a)
Compilation error
b)
macro25 = 47
c)
macro47 = 25
d)
Runtime error
27.
#include<stdio.h> #include<string.h> #define MACRO(num) ++num int main() { char *ptr = "preprocessor"; int num =strlen(ptr); printf("%s ", MACRO(ptr)); printf("%d", MACRO(num)); return 0; }
a)
preprocessor 12
b)
preprocessor 13
c)
reprocessor 13
d)
reprocessor 12
28.
#include<stdio.h> #define f(x,y) x##y int main() { printf("%d\n",f(5,6)); return 0; }
a)
5#6
b)
56
c)
5##6
d)
Compilation error
29.
What is the time complexity of the following code? int fun(int x) { if (x <= 0) return 1; return 1 + fun(x-1); }
a)
O(n)
b)
O (log n)
c)
O (n log n)
d)
O (log log n)
30.
What is the time complexity of the code? int fun(int x) { if (x <= 0) return 1; return 1 + fun(x/5); }
a)
O(n)
b)
O (log n)
c)
O (n log n)
d)
O (log log n)