C Practice Test 1

C Practice Test 1

University

12 Qs

quiz-placeholder

Similar activities

Arrays and Functions

Arrays and Functions

University

12 Qs

Programming 1

Programming 1

University

10 Qs

Java Basic Day-2

Java Basic Day-2

University

10 Qs

Tuan 3 - Python

Tuan 3 - Python

KG - Professional Development

10 Qs

Printf, scanf

Printf, scanf

University

12 Qs

TIU Quiz-9

TIU Quiz-9

University

10 Qs

SOII. Gestión ficheros y práctica

SOII. Gestión ficheros y práctica

University

10 Qs

Javascript

Javascript

University

12 Qs

C Practice Test 1

C Practice Test 1

Assessment

Quiz

Computers

University

Hard

Created by

Dipti Ranjan Lenka

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

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

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

By signing up, you agree to our Terms of Service & Privacy Policy

Already have an account?