Font size
WorksheetsC Programming - Medium
Total questions: 10
Worksheet time: 4mins
Whether C code will compile without main() function?
Yes
No
Format specifier for size_t is:
%s
%p
%zu
%ld
%i
What is output of this code:
#include <stdio.h>
int main(){
int y = 3;
printf("%d %d %d",y,y,y++,++y);
}
3 3 3
5 5 4
3 3 4
4 4 5
What is output of this code:
#include <stdio.h>
#define ARR_SIZE 10
int main(){
int arr[ARR_SIZE] = {-1};
int *ptr1 = &(arr[0]), *ptr2 = &(arr[4]);
printf("%p",ptr2-ptr1);}
4
Compile Error
0x4
0x16
16
Select existing signals
SIGILL
SIGTERM
SIGRET
SIGEXT
SIGFPE
In which libraries NULL macro is defined?
stdlib.h
stdio.h
assert.h
stddef.h
stdbool.h
Which macro may return 31?
int x = 2, y= 3, z;
z= RAT(x++,++y);
#define RAT (A,B) ( ((A) * (A)) + ((B) * (B)) )
#define RAT (A,B) ( ((A) * (2)) + ((B) * (2)) )
#define RAT(A,B) ( ((A) * (A)) + ((B) * (B)) )
#define RAT(A,B) ( ((A) * (2)) + ((B) * (2)) )
#define RAT(A,B) ( ((A) * (B)) + ((B) * (B)) )
What is output for this code:
int *p = (int*)malloc(sizeof(int));
int *q = (int*)realloc(p, sizeof(int));
*p = 1; *q = 2;
if (p == q) printf("%d%d", *p, *q);
Compile Error
12
Undefined Behaviour
22
Runtime Error
What is output for this code:
volatile static int x = 15;
fork();
printf("%d ",++x);
if (fork() == 0) {
x += 5; printf("%d ", x);
}else {
x -= 5; printf("%d ", x);}
16 11 16 21 16 11 16 21
16 11 16 21
16 11 17 11 18 21 19 21
11 16 11 16 21 16 21
16 11 16 11 16 21 16 21
Which one is NOT a C compiler
GCC
CFront
Clang
Icc
QuickC
