NEW
Font size
S
M
L
XL
WorksheetsVCE-ALPHA-25.11.2023-AN
Total questions: 15
Worksheet time: 15mins
Name
Class
Date
1.
#include <stdio.h>
int main() {
int arr[5];
printf("%d", sizeof(arr++));
return 0;
}
What will be the output of this program?
a)
1
b)
2
c)
4
d)
Compiler Error
2.
#include <stdio.h>
int main() {
int arr[] = {1, 2, 3, 4, 5};
printf("%p", arr + 3);
return 0;
}
What will be printed by this program?
a)
Address of arr[3]
b)
Address of arr[0]
c)
Address of arr[4]
d)
Address of arr
3.
#include <stdio.h>
int main() {
int arr[5] = {1, 2, 3, 4, 5};
printf("%d", arr[-2]);
return 0;
}
a)
3
b)
2
c)
1
d)
Compiler Error
4.
#include <stdio.h>
int main() {
int arr[5] = {1, 2, 3, 4, 5};
printf("%p", &arr[2]);
return 0;
}
a)
Address of arr[0]
b)
Address of arr[2]
c)
Address of arr[4]
d)
Compiler Error
5.
#include <stdio.h>
int main() {
int nums[] = {1, 2, 3, 4, 5};
printf("%d", nums[2] - nums[1]);
return 0;
}
a)
0
b)
1
c)
2
d)
3
6.
#include <stdio.h>
int main() {
int arr[5] = {1, 2, 3, 4, 5};
printf("%d", arr[3]++);
return 0;
}
a)
4
b)
5
c)
6
d)
Compiler Error
7.
int main() {
int data[5] = {1, 2, 3, 4, 5};
printf("%d", data[2] * 2);
return 0;
}
a)
2
b)
4
c)
6
d)
8
8.
What does the following C code snippet do?
int arr[4] = {1, 2, 3, 4};
int sum = 0;
for (int i = 0; i < 4; ++i) {
sum += arr[i] * i;
}
printf("%d", sum);
a)
Computes the factorial of the array elements
b)
Calculates the sum of the array indices
c)
Finds the product of array elements and their indices
d)
Counts the number of odd array elements
9.
#include <stdio.h>
void f(int a[2][])
{
a[0][1] = 3;
int i = 0, j = 0;
for (i = 0;i < 2; i++)
for (j = 0;j < 3; j++)
printf(""%d"", a[i][j]);
}
void main()
{
int a[2][3] = {0};
f(a);
}
a)
compile time error
b)
All junk values
c)
0 Only
d)
Runtime error
10.
#include "stdio.h"
#include "stdlib.h"
int main(int argc, char *argv[]) {
char temp[20];
gcvt(23.45,2, temp);
printf("%s", temp);
return 0;
}
a)
0.4
b)
24.4
c)
25.4
d)
23
11.
#include<stdio.h>
int main()
{
int a[5] = {5, 1, 15, 20, 25};
int i, j, m;
i = ++a[1];
j = a[1]++;
m = a[i++];
printf("%d, %d, %d", i, j, m);
return 0;
}
a)
2,5,15
b)
3, 2, 15
c)
1,2,5
d)
12,15,1
12.
#include <stdio.h>
int main() {
int arr[5] = {1, 2, 3, 4, 5};
printf("%d", arr[4]--);
return 0;
}
a)
4
b)
5
c)
6
d)
Compiler Error
13.
#include <stdio.h>
int main() {
int nums[3][2] = {{1, 2}, {3, 4}, {5, 6}};
printf("%d", nums[2][1] / nums[1][0]);
return 0;
}
a)
0
b)
1
c)
2
d)
3
14.
int main()
{
int a[3] = {20,30,40};
int b[3];
b=a;
printf("%d", b[0]);
}
a)
compiler error
b)
20
c)
30
15.
#include <stdio.h>
int main()
{
int ary[2][3][4], j = 20;
ary[0][0] = &j;
printf("%d\n", *ary[0][0]);
}
a)
Junk value
b)
No output
c)
Compile time Error
d)
Address of j
Reset
