WorksheetsFE1prf192
Total questions: 50
Worksheet time: 25mins
Who is the inventor of the C programming language?
Dennis Richie
Bjarne Stroustrup
Brian Kernighan
Niklaus Wirth
How does compilation differ from interpretation in the context of the C programming language?
Compilation involves converting source code into machine code, while interpretation executes the code line by line.
Compilation and interpretation are two terms used interchangeably.
Algorithm is another term for interpretation in programming languages.
The IDE tool is responsible for both compilation and interpretation processes.
What happens to comments during the compilation process?
The comment markers will be removed. The content of the comments will be compiled line by line.
Comments are treated as a character array.
Comments will be removed in the preprocessing step.
Each comment is compiled as a no-op statement.
What converts a C source file into machine language so that the computer can execute it?
A compiler
A text editor
A file
A program
The main purpose of the const keyword when used with function parameters in C is what?
It prevents the function from modifying the value of the parameter
It ensures the parameter is passed by reference
It limits the scope of the parameter within the function
It specifies that the parameter should be initialized
What is the size of a float variable in bytes?
2 bytes
1 byte
8 bytes
4 bytes
Which of the following is a valid variable definition?
int 1student_ID;
int _Student_ID1;
int Age$;
int long;
What is the output displayed on the screen of the following program?
0 1 1 2 3 3
0.5 1.0 1.5 2.5 3.0 3.5
1 1 2 3 3 4
0 1 1 2 23
If two strings have the same value, what does the strcmp() function return?
True
1
0
-1
What is the purpose of the strcpy() function in C programming?
copy a string
concatenate two strings
compare two strings
What is the result of the command "printf("%d %d", 12&5, 12/5);"?
4 13
5 12
4 12
5 13
11
What will be the result of the following C code?
Hi
How are you
Hello
HiHello
What is the & operator?
Bitwise AND
Bitwise OR
Logical AND
Logical OR
What term is commonly used to refer to both the type and the name of a variable or constant in the C programming language?
Identification
Name
Declaration
Definition
Which declaration is not supported by C?
string a;
float a = 3e2;
int* a;
float *a;
char * a;
What are the benefits of #define when handling magic numbers in code?
It improves the portability of the code
It makes the code shorter
It prevents the use of symbolic names
It increases the complexity of the code
In the sample code int a = 0x10 | 011; the variable a will contain the value (in decimal):
3
13
19
25
27
The result of the command "printf("%d", 0x11 | 010);" is what?
5
22
18
25
28
What is the result when the sample code below is executed?
1; 18; 120
10; 19; 60
What is the result when the sample code below is executed?
#include
1; 18; 120
10; 19; 60
1; 20; 60
10; 19; 120
What is the result when the sample code below is executed?
#include
1; 18; 120
10; 19; 60
1; 20; 60
10; 19; 120
What is the result when the sample code below is executed?
#include
Compilation error
1
2
return 1:return2
What is the difference between a while loop and a do-while loop?
The way the condition is checked.
They are basically the same.
The type of tasks they can perform.
Variables in the loop structure.
What is the purpose of the continue statement in a loop?
To skip the rest of the code inside the loop and move to the next iteration.
To jump to the beginning of the loop.
To exit the entire program.
To increment/decrement the variable in the loop.
Which programming technique is used to solve this complex problem by dividing the program into a series of smaller programs?
Modularity
Iteration
Selection
Sequential
What is the result when the sample code below is executed?
#include
Compilation error
6
4
5
Which function in the C language?
if()
return()
int()
is_prime()
#include()
What will be the result of the following C code?
#include
5
Runtime error
6
Garbage
Which function will calculate the average of two real numbers?
int average(double, double);
double average(double, double);
char average(double, double);
void average(double, double);
What is the result of the following code?
#include
22
10
12
21
The islower() function returns a non-zero value if a character is:
A lowercase letter
An uppercase letter
A digit
A punctuation character
What is the function of the command "fflush(stdin);"?
Output a string to the screen
Receive a string input from the keyboard
Clear the characters entered from the keyboard
Clear the remaining characters in the keyboard buffer
The correct function to clear the remaining characters in the keyboard buffer in C programming is
clearbuffer()
cleanbuffer()
flushall(in)
fflush(stdin)
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];}
{1, 2, 4, 5, 5}
{1, 2, 4, 5}
{1, 3, 4, 5}
{1, 2, 3, 4}
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];
Sum of the squares of all elements in array a.
Sum of all even elements in array a.
Sum of all odd elements in array a.
Sum of all elements in array a.
Given a matrix named mat with a size of 6x6, how do you access the element in the last row and last column?
mat[5][5]
mat[5][6]
mat[6][5]
mat[-1][-1]
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);
10
Compilation error
Runtime error
Garbage value
Choose the correct statement to declare a pointer variable to an integer variable.
int *p;
int p*;
int +p;
int $p;
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; }
333
111
222
Compilation error
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; }
102, 102
100, 102
100, 100
102, 100
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?
1264
1200
1208
1209
Which of the following statements is invalid?
printf('\');
printf("abc");
printf("%%");
printf("\n");
Which of the following is incorrect when outputting a string?
putc(s)
puts(s)
printf(s)
printf("%s",s)
printf("%s", &s)
Which function provides input buffering utilities on the standard input stream?
getchar(), scanf()
getchar(), fgets()
scanf(), fgetc()
fgets(), fgetc()
Which function is used to write a string to a file in C?
fputs()
fscanf()
fgets()
fopen()
To read an entire line from a file in C, which function is commonly used?
fgets()
gets()
readLine()
scanLine()
What is the purpose of the fscanf() function in the C programming language?
Close a file.
Print to the screen.
Read data from a file.
Open a file.
Read data from the keyboard.
Which function is used to read a line from a specified stream and store it in the specified string from a file?
fgets
fgetc
fputs
fpusc
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));
400 byte and 400 byte
400 byte and 100 byte
100 byte and 800 byte
100 byte and 400 byte
Consider the following program and answer the following questions. #include
t=0 p=4.000000 t = 2, p = 6.000000
t = 0, p=4.00000 t = 2, p = 5.000000
t=0, p = 4.000000 t=2, p=4.500000
t=0 p=4.0000000 t=2, p=4.000000
