wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

VCE-GAMMA-21.11.2023-FN

Total questions: 15

Worksheet time: 15mins

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