C Practice Test 1

C Practice Test 1

University

12 Qs

quiz-placeholder

Similar activities

Operators

Operators

University

12 Qs

Java Quiz2

Java Quiz2

University

11 Qs

Structures and union

Structures and union

University

15 Qs

Operators in C

Operators in C

University

12 Qs

TECHNICAL C PROGRAM

TECHNICAL C PROGRAM

University

10 Qs

C programming-1

C programming-1

University

13 Qs

Programación (Estructuras, acceso a miembro y mem. dinámica)

Programación (Estructuras, acceso a miembro y mem. dinámica)

University

10 Qs

C MCQ's for Interview

C MCQ's for Interview

University

10 Qs

C Practice Test 1

C Practice Test 1

Assessment

Quiz

Computers

University

Hard

Created by

Dipti Ranjan Lenka

FREE Resource

12 questions

Show all answers

1.

OPEN ENDED QUESTION

30 sec • Ungraded

Branch

Evaluate responses using AI:

OFF

2.

OPEN ENDED QUESTION

30 sec • Ungraded

Roll No

Evaluate responses using AI:

OFF

3.

OPEN ENDED QUESTION

30 sec • Ungraded

Name

Evaluate responses using AI:

OFF

4.

MULTIPLE CHOICE QUESTION

30 sec • 2 pts

Suppose that in a C program snippet, followings statements are used. i) sizeof(int); ii) sizeof(int*); iii) sizeof(int**); Assuming size of pointer is 4 bytes and size of int is also 4 bytes, pick the most correct answer from the given options.
Suppose that in a C program snippet, followings statements are used.
i), ii) and iii) would compile successfully and size of each would be same i.e. 4
i), ii) and iii) would compile successfully but the size of each would be different and would be decided at run time.
ii) and iii) would result in compile error but i) would compile and result in size as 4.

5.

MULTIPLE CHOICE QUESTION

30 sec • 2 pts

Assume int is 4 bytes, char is 1 byte and float is 4 bytes. Also, assume that pointer size is 4 bytes (i.e. typical case) char *pChar; int *pInt; float *pFloat; sizeof(pChar); sizeof(pInt); sizeof(pFloat); What’s the size returned for each of sizeof() operator?
4 4 4
1 4 4
1 4 8
None of the above

6.

MULTIPLE CHOICE QUESTION

30 sec • 2 pts

#include "stdlib.h" int main() { int *pInt; int **ppInt1; int **ppInt2; pInt = (int*)malloc(sizeof(int)); ppInt1 = (int**)malloc(10*sizeof(int*)); ppInt2 = (int**)malloc(10*sizeof(int*)); free(pInt); free(ppInt1); free(*ppInt2); return 0; } Choose the correct statement w.r.t. above C program.
malloc() for ppInt1 and ppInt2 isn’t correct. It’ll give compile time error.
free(*ppInt2) is not correct. It’ll give compile time error.
free(*ppInt2) is not correct. It’ll give run time error.
No issue with any of the malloc() and free() i.e. no compile/run time error.

7.

MULTIPLE CHOICE QUESTION

30 sec • 2 pts

#include "stdio.h" int main() { void *pVoid; pVoid = (void*)0; printf("%lu",sizeof(pVoid)); return 0; } Pick the best statement for the above C program snippet.
Assigning (void *)0 to pVoid isn’t correct because memory hasn’t been allocated. That’s why no compile error but it'll result in run time error.
Assigning (void *)0 to pVoid isn’t correct because a hard coded value (here zero i.e. 0) can’t assigned to any pointer. That’s why it'll result in compile error.
No compile issue and no run time issue. And the size of the void pointer i.e. pVoid would equal to size of int.
sizeof() operator isn’t defined for a pointer of void type.

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?