wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

KLU- CLUSTER -5 DAY-2

Total questions: 30

Worksheet time: 30mins

Name
Class
Date
1.
#include<stdio.h> int main(){ int a, b, c; char *p = 0; int *q = 0; double *r = 0; a = (int)(p + 1); b = (int)(q + 1); c = (int)(r + 1); printf("%d %d %d",a, b, c); return 0; }
a)
Runtime error
b)
0 0 0
c)
Compilation error
d)
1 4 8
2.
#include<stdio.h> int main() { char *ptr; char string[] = "CampusConnect"; ptr = string; ptr += 6; printf("%s",ptr); return 0; }
a)
compilation error
b)
Runtime error
c)
CampusConnect
d)
Connect
3.
#include<stdio.h> int main() { const int a = 5; const int *ptr; ptr = &a; *ptr = 10; printf("%d\n", a); return 0; }
a)
Compilation error
b)
Garbage Value
c)
Address
d)
5
4.
#include<stdio.h> int main() { printf("%d", sizeof(void *)); return 0; }
a)
1
b)
compilation error
c)
Runtime error
d)
4
5.
#include<stdio.h> int main(){ char arr[15] = "pointer array"; int *ptr; ptr = arr; printf("%c",ptr[1]); return 0; }
a)
Garbage value
b)
o
c)
t
d)
Compile time error
6.
#include<stdio.h> int main() { int a = 10, b = 6; int *ptr; ptr = &b; printf(" %d ", a **ptr); return 0; }
a)
Pointer type error
b)
Run time error
c)
Compilation error
d)
60
7.
#include<stdio.h> int main(){ char array[5] = "Knot", *ptr, i, *ptr1; ptr = &array[1]; ptr1 = ptr + 3; *ptr1 = 101; for(i = 0; i < 4;i++) printf("%c", *ptr++); return 0; }
a)
not
b)
Knot
c)
note
d)
garbage value
8.
#include<stdio.h> int main() { char *ptr = "Pointer-to-String", i; printf("%s", ++ptr); return 0; }
a)
Pointer-to-String
b)
o
c)
ointer-to-String
d)
None of the above
9.
#include<stdio.h> int main() { char *str = "His"; int i; for(i = 0; i < strlen(str); i++) printf("%s", str++); return 0; }
a)
Hisis
b)
Hisiss
c)
HisHisHis
d)
None of the above
10.
#include<stdio.h> int main() { char arr[10] = "Mango", *ptr; ptr = (&arr[1]++); printf("%s",ptr++); return 0; }
a)
ango
b)
ngo
c)
Compile time error
d)
Mango
11.
#include<stdio.h> int main(){ int i = 5; void *vptr; vptr = &i; printf("\nValue of iptr = %d ", *vptr); return 0; }
a)
5
b)
garbage address
c)
garbage value
d)
Compile time error
12.
#include<stdio.h> int main(){ switch(*(3 + "I LOVE" "ABCD" + 3)){ case 'A': printf("Apple Mac"); break; case 'B': printf("Windows"); break; case 'C': printf("Great Linux"); break; default: printf("All the above");} return 0; }
a)
Apple Mac
b)
Windows
c)
Great Linux
d)
All the above
13.
#include<stdio.h> int main(){ char *str1 = "First"; char *str2 = "Second"; switch(*str1){ case "First": printf("USAIN BOLT"); break; case "Second": printf("JUSTIN GATLIN"); break; default: printf("Others"); } return 0; }
a)
USAIN BOLT
b)
JUSTIN GATLIN
c)
Compilation Error
d)
Others
14.
#include<stdio.h> int main(){ char *str = "ABCD"; switch(*str + 2){ case 'A': printf("Apple"); break; case 'B': printf("BOOK"); break; case 'C': printf("CLOUD"); break; case 'D': printf("DELL"); break; } return 0; }
a)
CLOUD
b)
BOOK
c)
APPLE
d)
Compilation Error
15.
#include<stdio.h> int main(){ char ch = '\0'; switch(ch){ case NULL: printf("Empty \0"); break; case ' ': printf("Empty Empty"); break; case '0': printf("Empty 0"); break; default: printf("Nothing"); } return 0; }
a)
Empty \0
b)
Empty Empty
c)
Empty 0
d)
None of the above
16.
#include<stdio.h> int main(){ struct simp{ int i = 6; char city[] = "chennai"; }; struct simp s1; printf("%d",s1.city); printf("%d", s1.i); return 0; }
a)
chennai 6
b)
Nothing will be displayed
c)
Runtime Error
d)
Compilation Error
17.
#include<stdio.h> int main(){ struct st { int i; static int si; }; struct st s = {1, 2}; printf("%d %d", s.i, s.si); return 0; }
a)
1 2
b)
Linker Error
c)
Runtime Error
d)
Compilation Error
18.
void main() { struct bitfields { int bits_1: 2; int bits_2: 9; int bits_3: 6; int bits_4: 1; }bit; printf("%d", sizeof(bit)); }
a)
2
b)
3
c)
4
d)

0

19.
#include<stdio.h> int main() { struct leader { char *lead; int born; }; struct leader l1 = {"AbdulKalam", 1931}; struct leader l2 = l1; printf("%s %d", l2.lead, l1.born); }
a)
Compilation error
b)
Garbage value 1931
c)
AbdulKalam 1931
d)
None of the above
20.
#include<stdio.h> struct employee{ char *company; int salary; }; int main(){ struct employee e, e1; e.company = "CCC"; e1 = e; printf("%s %s", e.company, e1.company); return 0; }
a)
Garbage value CCC
b)
CCC Garbage value
c)
CCC CCC
d)
Compilation Error
21.
#include<stdio.h> int main(){ struct employee { int empid[5]; int salary; struct employee *s; }emp; printf("%d %d", sizeof(struct employee), sizeof(emp.empid)); return 0; }
a)
6 4
b)
36 20
c)
32 20
d)
40 10
22.
#include<stdio.h> #include<string.h> struct player { char pname[20]; }pl; char* play(struct player *temp_pl){ strcpy(temp_pl->pname, "kohli"); return temp_pl->pname; } int main() { strcpy(pl.pname, "dhoni"); printf("%s %s", pl.pname, play(&pl)); return 0; }
a)
dhoni kohli
b)
dhoni dhoni
c)
None
d)
kohli kohli
23.
#include<stdio.h> struct TeamScore{ int wickets; int score; }ts = {2, 325}; struct country{ char *name; }nation = {"India"}; int main() { struct TeamScore tcon = ts; printf("%d %d %s", tcon.score, ts.wickets, nation.name); return 0; }
a)
325 2 India
b)
325 2 garbage value
c)
compilation error
d)
None of the above
24.
#include<stdio.h> int main(){ struct sample{ int employees; char comp[5]; struct founder{ char ceo[20]; }p; }; struct sample c = {4000, "CCC", "SN"}; printf("%s %d %s", c.comp, c.employees, c.p.ceo); return 0; }
a)
CCC garbage value garbage value
b)
CCC garbage value SN
c)
CCC 4000 SN
d)
CCC 4000 CCC
25.
#include<stdio.h> int main(){ struct branch{ char bran[10] = "Bangalore"; int bpin = 431; }; struct headoff{ char head[10]; int hpin; }; struct headoff h = {"Chennai", 01}; struct branch b; printf("HO - %s \n hpin - %d", h.head, h.hpin); printf("BO - %s \n bpin - %d", b.bran, b.bpin); }
a)
HO - Chennai hpin - 01 BO - Bangalore 431
b)
HO - Chennai hpin - 01
c)
Compilation Error
d)
Runtime Error
26.
#include<stdio.h> int main(){ struct str{ int s1; char st[30]; }; struct str s[] = { {1, "struct1"}, {2, "struct2"}, {3, "struct3"} }; printf("%d %s", s[2].s1, (*(s+2)).st); }
a)
Compilation Error
b)
1 struct1
c)
2 struct2
d)
3 struct3
27.
#include<stdio.h> int main(){ struct play{ char name[10]; int playnum; }; struct play p1 = {"virat", 18}; struct play p2 = p1; if(p1 == p2) printf("Two structure members are equal"); return 0; }
a)
Compilation Error
b)
Two structure members are equal
c)
Nothing will be display
d)
Runtime Error
28.
#include<stdio.h> int main() { enum numbers{num1, num2 = 0, num3, num4, num5, num6}n; printf("%d\n", sizeof(n)); }
a)
12
b)
4
c)
2
d)
None of the above
29.
#include<stdio.h> int main() { struct check { }ck; printf("%d", sizeof(ck)); }
a)
0
b)
1
c)
Compilation Error
d)
None
30.
#include<stdio.h> int main() { struct check { int i:0; }ck; printf("%d", sizeof(ck)); }
a)
0
b)
2
c)
Compilation Error
d)
4