NEW
Font size
WorksheetsSESSIONAL EXAM(Programmin Lab)
Total questions: 15
Worksheet time: 14mins
Which of the following function is used to allocate memory and initialize it to zero?
What is the correct syntax to dynamically allocate memory for an array of 10 integers?
What is the size of a structure containing an int and a char (assuming 4-byte int and 1-byte char on a 4-byte aligned machine)?
union data {
int i;
float f;
};
union data d;
d.i = 10;
d.f = 3.14;
printf("%d", d.i);
int fun(int n) {
if (n == 0) return 0;
else return n + fun(n - 1);
}
int main(){
printf("%d", fun(3));
return 0;
}
void print(int n) {
if (n == 0) return;
print(n - 1);
printf("%d ", n);
}
int main(){
print(3);
return 0;
}
int a = 5, b = 10;
int p = &a, q = &b;
*p = *q;
printf("%d %d", a, b);
void fun(int *p) {
p = p + 10;
}
int main() {
int x = 5;
fun(&x);
printf("%d", x);
}
5
15
garbage
What will be the size of the array declared as char name[] = "C Programming";?
void test(int a) {
a = a + 5;
}
int main() {
int x = 10;
test(x);
printf("%d", x);
}
int main(){
int arr[3] = {1, 2};
printf("%d", arr[2]);
return 0;
}
garbage value
int arr[] = {1, 2, 3, 4};
printf("%lu", sizeof(arr));
4
16
3
int main(){
int i = 0;
while(i++ < 3){
printf("%d ", i);
}
return 0;
}
int main(){
int x = 0;
if (x)
printf("True");
else
printf("False");
return 0;
}
What is the result of the expression ++a - b++ when a = 5 and b = 3?
