WorksheetsC Programming Quiz
Total questions: 62
Worksheet time: 31mins
Which of the following is not a valid variable name?
_bca_90
90_bca_
bca29
programmingLanguage_
Which of the following functions reads multiple characters from the keyboard?
getchar()
getche()
getch()
gets()
The statement used in C to branch unconditionally from one point to another:
if
if...else...
goto
switch
Which of the following is an exit-controlled loop?
while
do...while
for
if
Function header does not consist of:
function type
function name
local variable declaration
list of parameters
In an array, subscript begins at:
zero
one
n-1
n
When operator is placed before a pointer variable in an expression, it means:
address of
value at address
address of pointer variable
address of main
The string function that compares two strings is:
strlen()
strcat()
strcmp()
strcomp()
The function that reads an integer from a file is:
putw()
getw()
fseek()
ftell()
Which of the following statements is not valid?
C does not permit initialization of individual structure members within the template.
Initialization must be done only in the declaration of the actual variables.
The order of values enclosed in braces must match order of members in the structure definition.
It is not permitted to have partial initialization.
_____ are the names you supply for variables, types, functions and labels in your program.
Constants
Variables
Identifiers
Keywords
Which header file can be used to define input/output function prototypes and macros?
math.h
memory.h
stdio.h
conio.h
Storage size of type unsigned int is:
1 byte
2 bytes
4 bytes
8 bytes
Which printf() statement will you use to print out a (float value) and b (double value)?
printf("%f%lf", a, b);
printf("%f%f", a, b);
printf("%Lf%Lf", a, b);
printf("%f%Lf", a, b);
The default parameter passing mechanism is:
call by value
call by reference
call by value result
call by function
A recursive function is faster than _____ loop.
for
while
do while
None of the above
How do you initialize an array in C?
intarr[3] = (1,2,3);
intarr(3) = {1,2,3};
intarr[3] = {1,2,3};
intarr(3) = (1,2,3);
What is the value of an array element which is not initialized?
By default zero 0
1
Depends on storage class
None of the above
FILE is of:
int type
char * type
struct type
None of the above
C structure or user-defined data type is also called:
derived data type
secondary data type
aggregate data type
All of the above
The C programming language was originally developed by:
Ken Thompson
Dennis M. Ritchie
Brian Kernighan
Mark Zuckerberg
The C programming language is:
high-level language
assembly language
machine language
scripting language
What will be the output for the following code? #include int main( ) { int a = 5, b = 5; printf("%d", a+++--b); return 0; }
10
9
8
7
What will be the output for the following code? #include int main( ) { int a = 0; while( )a = 0 { printf("a d= % ", a); } return 0; }
a = 0
0
No output
Syntax error
The return type void returns:
integer
float
character
nothing
Any C program:
must contain at least one function
needs not contain any function
needs input data
None of the above
What is the right way to initialize an array?
int num[] = {6, 2, 4, 12, 5, 45};
int n = {2, 4, 12, 5, 45, 5};
int n[6] = {2, 4, 12};
int n() = {6, 2, 4, 12, 5, 45};
What is the meaning of the following code about pointers? int *ptr, p;
ptr is a pointer to integer, p is not
ptr and p, both are pointers to integer
ptr is pointer to integer, p may or may not be
ptr and p both are not pointer to integer
Select a function which is used to write a string to a file:
puts()
putc()
fputs()
fgets()
What is a structure in C language?
A structure is a collection of elements that can be of same data type
A structure is a collection of elements that can be of different data types
Elements of a structure are called members
All of the above
What is the right way to initialize an array?
int num[6] = {2, 4, 12, 5, 45, 5};
int n{ } = {2, 4, 12, 5, 45, 5};
int n{6} = {2, 4, 12};
int n{6} = {2, 4, 12, 5, 45, 5};
The symbol || is used to represent logical:
AND
OR
NOT
NAND
The ?: operator is known as:
arithmetic
conditional
binary
loop
o represent logical:
AND
OR
NOT
NAND
The ?: operator is known as:
arithmetic
conditional
binary
loop
The field specification for reading an integer number is:
%c
%f
%1f
%d
What will be the result of 9 % 2 in a C program?
0
1
2
4
What is the output of the following code? int main() { int x = 10; { int x = 0; printf("%d", x); } return 0; }
10
Compilation error
0
Undefined
Which of the following is the correct syntax to send an array as a parameter to a function?
func(&array);
func(#array);
func(*array);
func(array[size]);
What is the output of the following program? #include int main() { char c; FILE *fp; fp = fopen("demo.txt", "r"); while((c = fgetc(fp)) != EOF) printf("%c", c); fclose(fp); return 0; }
It will print the content till newline
It will print the content of file demo.txt
Compilation error
Undefined
A pointer is:
a keyword used to create variables
a variable that stores the address of another variable
a variable that stores the address of an instruction
All of the above
The size of a union is determined by the size of the:
first member in the union
last member in the union
biggest member in the union
sum of the sizes of all members
Which of the following is not a valid C variable name?
int number;
float rate;
int variable_count;
int main#;
Which of the following declarations is not supported by C language?
String str;
char *str;
float str = 3e2;
int a[2] [2];
Which of the following is an example of iteration in C?
for
while
do-while
All of the above
How many times i value is checked in the following C program?
#include<stdio.h> int main(void) { int i=0; while(i<3) i++; printf("In while loop\n"); }
2
3
4
1
void main() { int x = 5 * 9 / 3 + 9; }
3.75
4.09
24
3
Which keyword can be used to come out of recursion?
break
return
exit
Both break and return
What are the elements present in the array of the following C code? Int array[5] = {5};
5, 5, 5, 5, 5
5, (garbage), (garbage), (garbage), (garbage)
5, 0, 0, 0, 0
(garbage), (garbage), (garbage), (garbage), 5
Which of the following is an indirection operator?
&
*
->
.
Which of the following are themselves a collection of different data types?
string
structures
char
array
What is meant by 'a' in the following C operation? fp = fopen("Random.txt", "a");
Attach
Append
Apprehend
Add
How many main () functions can we have in any program?
1
2
No limit
Depends on compiler
What will be the data type of the result of the following operation? (float)a* (int) b / (long) c * (double) d
int
long
float
double
A user-defined data type, which is used to assign names to integral constants is called
union
structure
array
enum
What is the output? int main () { int n; for (n=9; n>=0; n--) printf ("n=%d", n--); return (); }
9 7 5 3 1
9 8 7 6 5 4 3 2 1
infinite loop
9 7 5 3
What is the output of the following? int main () { int x=10; { int x=0; printf ("%d", x); } return 0; }
10
Compilation error
0
Undefined
Value of static storage variable
changes during different function calls
persists between different function calls
increase during different function calls
decrease during different function calls
Which of the following is the correct syntax to send an array as a parameter to the function?
func (*array)
func (array[size])
func (&array)
func (array)
Which of the following is correct about the program?
j is a pointer to an int and stores the address of i
j and i are pointers to an int
i is a pointer to an int and stores the address of j
j is a pointer to a pointer to an int and stores the address of i
Which of the following operations is illegal in a structure?
Pointer to a variable of the same structure
Dynamic allocation of memory for structure
Typecasting of structure
Both (a) and (b)
Choose the right statement for fscanf() and scanf():
fscanf() can read from standard input whereas scanf() specifies a stream from which to read()
fscanf() can specify a stream from which to read whereas scanf() can read only from standard input
fscanf() and scanf() have no difference in their functions
fscanf() and scanf() can read from the specified stream
