wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

FE1prf192

Total questions: 50

Worksheet time: 25mins

Name
Class
Date
1.

Who is the inventor of the C programming language?

a)

Dennis Richie

b)

Bjarne Stroustrup

c)

Brian Kernighan

d)

Niklaus Wirth

2.

How does compilation differ from interpretation in the context of the C programming language?

a)

Compilation involves converting source code into machine code, while interpretation executes the code line by line.

b)

Compilation and interpretation are two terms used interchangeably.

c)

Algorithm is another term for interpretation in programming languages.

d)

The IDE tool is responsible for both compilation and interpretation processes.

3.

What happens to comments during the compilation process?

a)

The comment markers will be removed. The content of the comments will be compiled line by line.

b)

Comments are treated as a character array.

c)

Comments will be removed in the preprocessing step.

d)

Each comment is compiled as a no-op statement.

4.

What converts a C source file into machine language so that the computer can execute it?

a)

A compiler

b)

A text editor

c)

A file

d)

A program

5.

The main purpose of the const keyword when used with function parameters in C is what?

a)

It prevents the function from modifying the value of the parameter

b)

It ensures the parameter is passed by reference

c)

It limits the scope of the parameter within the function

d)

It specifies that the parameter should be initialized

6.

What is the size of a float variable in bytes?

a)

2 bytes

b)

1 byte

c)

8 bytes

d)

4 bytes

7.

Which of the following is a valid variable definition?

a)

int 1student_ID;

b)

int _Student_ID1;

c)

int Age$;

d)

int long;

8.

What is the output displayed on the screen of the following program?

a)

0 1 1 2 3 3

b)

0.5 1.0 1.5 2.5 3.0 3.5

c)

1 1 2 3 3 4

d)

0 1 1 2 23

9.

If two strings have the same value, what does the strcmp() function return?

a)

True

b)

1

c)

0

d)

-1

10.

What is the purpose of the strcpy() function in C programming?

a)

copy a string

b)

concatenate two strings

c)

compare two strings

11.

What is the result of the command "printf("%d %d", 12&5, 12/5);"?

a)

4 13

b)

5 12

c)

4 12

d)

5 13

e)

11

12.

What will be the result of the following C code?

a)

Hi

b)

How are you

c)

Hello

d)

HiHello

13.

What is the & operator?

a)

Bitwise AND

b)

Bitwise OR

c)

Logical AND

d)

Logical OR

14.

What term is commonly used to refer to both the type and the name of a variable or constant in the C programming language?

a)

Identification

b)

Name

c)

Declaration

d)

Definition

15.

Which declaration is not supported by C?

a)

string a;

b)

float a = 3e2;

c)

int* a;

d)

float *a;

e)

char * a;

16.

What are the benefits of #define when handling magic numbers in code?

a)

It improves the portability of the code

b)

It makes the code shorter

c)

It prevents the use of symbolic names

d)

It increases the complexity of the code

17.

In the sample code int a = 0x10 | 011; the variable a will contain the value (in decimal):

a)

3

b)

13

c)

19

d)

25

e)

27

18.

The result of the command "printf("%d", 0x11 | 010);" is what?

a)

5

b)

22

c)

18

d)

25

e)

28

19.

What is the result when the sample code below is executed?

a)

1; 18; 120

b)

10; 19; 60

20.

What is the result when the sample code below is executed? #include int main(){int a=10,b=20,c=30;while(a>1){if(b%2!=0)a/=10;b--;c*=2;}printf("%d %d; %d",a,b,c);return 0;}

a)

1; 18; 120

b)

10; 19; 60

c)

1; 20; 60

d)

10; 19; 120

21.

What is the result when the sample code below is executed? #include int main(){int a=10,b=20,c=30;while(a>1){if(b%2!=0)a/=10;b--;c*=2;}printf("%d %d; %d",a,b,c);return 0;}

a)

1; 18; 120

b)

10; 19; 60

c)

1; 20; 60

d)

10; 19; 120

22.

What is the result when the sample code below is executed? #include int main() { } 20 > 30? return 1: return 2;

a)

Compilation error

b)

1

c)

2

d)

return 1:return2

23.

What is the difference between a while loop and a do-while loop?

a)

The way the condition is checked.

b)

They are basically the same.

c)

The type of tasks they can perform.

d)

Variables in the loop structure.

24.

What is the purpose of the continue statement in a loop?

a)

To skip the rest of the code inside the loop and move to the next iteration.

b)

To jump to the beginning of the loop.

c)

To exit the entire program.

d)

To increment/decrement the variable in the loop.

25.

Which programming technique is used to solve this complex problem by dividing the program into a series of smaller programs?

a)

Modularity

b)

Iteration

c)

Selection

d)

Sequential

26.

What is the result when the sample code below is executed? #include int main() { const int a=5; if(a>3) a++:break; a--; else printf("%d",a);return 0; FUOVERFL }

a)

Compilation error

b)

6

c)

4

d)

5

27.

Which function in the C language?

a)

if()

b)

return()

c)

int()

d)

is_prime()

e)

#include()

28.

What will be the result of the following C code? #include void main() { int k = 5;int *p = &k;int **m = &p;**m = 6:printf("%d\n", k);}

a)

5

b)

Runtime error

c)

6

d)

Garbage

29.

Which function will calculate the average of two real numbers?

a)

int average(double, double);

b)

double average(double, double);

c)

char average(double, double);

d)

void average(double, double);

30.

What is the result of the following code? #include int num(int a, int b){int sum; sum = a + b;return sum; } int main(){ int a, b, result; a = 10;b= 12; result = num(a, b); printf("%d", result); return 0; FUOVER }

a)

22

b)

10

c)

12

d)

21

31.

The islower() function returns a non-zero value if a character is:

a)

A lowercase letter

b)

An uppercase letter

c)

A digit

d)

A punctuation character

32.

What is the function of the command "fflush(stdin);"?

a)

Output a string to the screen

b)

Receive a string input from the keyboard

c)

Clear the characters entered from the keyboard

d)

Clear the remaining characters in the keyboard buffer

33.

The correct function to clear the remaining characters in the keyboard buffer in C programming is

a)

clearbuffer()

b)

cleanbuffer()

c)

flushall(in)

d)

fflush(stdin)

34.

Among the following options, which one correctly represents the array that has been updated after executing the code snippet below? int a[] = {1, 2, 3, 4, 5};for (i = 2; i < 4; i++){a[i] = a[i + 1];}

a)

{1, 2, 4, 5, 5}

b)

{1, 2, 4, 5}

c)

{1, 3, 4, 5}

d)

{1, 2, 3, 4}

35.

Given an array named a, what does the following code calculate? ZE];int s = 0;for (int i = 0; i < n; i++)s = s + a[i] * a[i];

a)

Sum of the squares of all elements in array a.

b)

Sum of all even elements in array a.

c)

Sum of all odd elements in array a.

d)

Sum of all elements in array a.

36.

Given a matrix named mat with a size of 6x6, how do you access the element in the last row and last column?

a)

mat[5][5]

b)

mat[5][6]

c)

mat[6][5]

d)

mat[-1][-1]

37.

int a[] = {1,2,3,4}; What will be displayed on the screen after executing the following code: int i=0, s=0;for (; a[i]; ++i)s += a[i]; printf("%d", s);

a)

10

b)

Compilation error

c)

Runtime error

d)

Garbage value

38.

Choose the correct statement to declare a pointer variable to an integer variable.

a)

int *p;

b)

int p*;

c)

int +p;

d)

int $p;

39.

What will be the result of the following program? int main() { int i = 1; int *p = &i;int **k = &p; i+=2; printf("%d%d%d", *p, **k, *(*k)); getchar(); return 0; }

a)

333

b)

111

c)

222

d)

Compilation error

40.

What will be the result of the following program? int main() { int i = 100; int *p = &i;*p +=2; printf("%d, %d", i, *p); getchar(); return 0; }

a)

102, 102

b)

100, 102

c)

100, 100

d)

102, 100

41.

Suppose we have the following code: double d=9; double *p = &d; Assuming a double occupies 8 bytes of memory, and the address of d is 1200. What is the result of the expression: p + 8?

a)

1264

b)

1200

c)

1208

d)

1209

42.

Which of the following statements is invalid?

a)

printf('\');

b)

printf("abc");

c)

printf("%%");

d)

printf("\n");

43.

Which of the following is incorrect when outputting a string?

a)

putc(s)

b)

puts(s)

c)

printf(s)

d)

printf("%s",s)

e)

printf("%s", &s)

44.

Which function provides input buffering utilities on the standard input stream?

a)

getchar(), scanf()

b)

getchar(), fgets()

c)

scanf(), fgetc()

d)

fgets(), fgetc()

45.

Which function is used to write a string to a file in C?

a)

fputs()

b)

fscanf()

c)

fgets()

d)

fopen()

46.

To read an entire line from a file in C, which function is commonly used?

a)

fgets()

b)

gets()

c)

readLine()

d)

scanLine()

47.

What is the purpose of the fscanf() function in the C programming language?

a)

Close a file.

b)

Print to the screen.

c)

Read data from a file.

d)

Open a file.

e)

Read data from the keyboard.

48.

Which function is used to read a line from a specified stream and store it in the specified string from a file?

a)

fgets

b)

fgetc

c)

fputs

d)

fpusc

49.

What are the sizes of the memory blocks allocated for d and e? int size = 100; float *d = malloc(size); float *e = calloc(size, sizeof(float));

a)

400 byte and 400 byte

b)

400 byte and 100 byte

c)

100 byte and 800 byte

d)

100 byte and 400 byte

50.

Consider the following program and answer the following questions. #include void updatePosition(int *time, float* position, float v) { else *position += -0.1*(*position);time += 1;} if ((*position < 5) && (*position > -5))*position += v; main() { float p=4.0, v=1; int t=0; printf("t = %d, p = %f\n", t, p); updatePosition(&t, &p, v); updatePosition(&t, &p, v); printf("t = %d, p = %f\n", t, p); } What is the output displayed on the screen?

a)

t=0 p=4.000000 t = 2, p = 6.000000

b)

t = 0, p=4.00000 t = 2, p = 5.000000

c)

t=0, p = 4.000000 t=2, p=4.500000

d)

t=0 p=4.0000000 t=2, p=4.000000