NEW
Font size
WorksheetsC Programming
Total questions: 40
Worksheet time: 40mins
Which of the following cannot be a variable name in C?
volatile
true
friend
export
Which of the following declaration is not supported by C?
String str;
char *str;
float str = 3e2;
both String str; & float str = 3e2;
Which keyword is used to prevent any changes in the variable within a C program?
immutable
mutable
const
volatile
What is the result of logical or relational expression in C?
True or False
0 or 1
0 if an expression is false and any positive number if an expression is true
none of the mentioned
What is the Format specifier used to print a Character array in C Printf or Scanf function?
%c
%C
%s
%d
What is the output of C Program with Strings?
globy
globy\0
compiler error
‘g’ ‘l’ ‘o’ ‘b’ ‘y’
How do you convert this char array to string?
char str[]={'g','l','o','b','y'};
str[5] = 0;
str[5] = '\0'
str[]={'g','l','o','b','y','\0'};
All of the above
What is the output of the following program?
30
20
compile time error
run time error
In C a pointer variable to an integer can be created by the declaration
int p*;
int *p;
int +p;
int $p;
Will this program compile ?
Yes
No
Which function is used to delete the allocated memory space ?
Dealloc()
free()
Both a and b
None of the above
malloc() allocates memory from the heap and not from the stack.
TRUE
FALSE
May Be
Can't Say
What is the output of C Program with switch statement ?
ANT KING PALACE
KING PALACE
ANT PALACE
Compiler error for using expressions
What is the output of C Program with switch statement or block ?
BOAT CHILLY
BOAT PETROL CHILLY
SHIP BOAT CHILLY
Compiler error
What is right way to Initialize 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 };
What will be the output of the program ?
3,2,15
2,3,20
2,1,15
1,2,5
An array elements are always stored in ________ memory location.
SEQUENTIAL
RANDOM
SEQUENTIAL AND RANDOM
NONE OF THE ABOVE
Let x be an array. Which of the following operations are illegal?
I. ++x
II. x+1
III. x++
IV. x*2
I and II
I,II and III
II and III
I,III and IV
III and IV
What is the maximun number of dimensions an array in C may have?
Two
eight
sixteen
Theoratically no limit. The only practical limits are memory size and compilers
Array is an example of _______ type memory allocation.
Compile time
Run time
Both A and B
None of the above
Size of the array need not be specified, when
Initialization is a part of definition
It is a formal parameter
It is a declaratrion
All of the above
The following code is an example of?
double da = 4.5;
double db = 4.6;
double dc = 4.9;
int result = (int)da + (int)db + (int)dc;
printf(""result = %d"", result);
Implicit Type Conversion
Explicit Type Conversion
Error
Cannot say
The data structure used to implement recursive function calls _____________.
Array
Linked List
Binary tree
Stack
What will be output for the following code?
Hello is printed once
Hello will be printed infinite number of times
Hello is not printed at all
0 is returned
OUTPUT OF THE PROGRAM
5Good Morning
M
Good
Morning
None of the above
What does the following declaration mean?
int (*ptr)[10];
ptr is array of pointers to 10 integers
ptr is a pointer to array of 10 integers
ptr is an array of 10 integers
ptr is a pointer to array
What will be the output of the following C code?
0
1
Compile time error
Undefined behaviour
What will be the output of the following C code?
i,am
iam
i am
error
The______function returns a pointer to the first character of a token.
strstr()
strcpy()
strspn()
strtok()
What is the output of the following code ?
6
9
12
8
What does this declaration mean?
int x : 4;
X is a four-digit integer.
X cannot be greater than a four-digit integer.
X is a four-bit integer.
None of the these
How many times will the following loop execute?
for(j = 1; j <= 10; j = j-1)
Forever
Never
0
1
What is the result after execution of the following code if a is 10, b is 5, and c is 10?
a = 10, c = 10
a = 11, c = 10
a = 10, c = 11
a = 11, c = 11
What will happen if the following C code is executed?
It will cause a compile-time error
It will cause a run-time error
It will run without any error and prints 3
It will experience infinite looping
What will be the final value of x in the following C code?
3.75
Depends on compiler
24
3
What will be the output of the following C code? (Initial values: x= 7, y = 8)
7.000000, 7
Run time error
7.000000, junk
Varies
What will be the output of the following C code snippet?
returns 1
returns 2
varies
compile time error
What will be the data type returned for the following C function?
char
int
double
multiple type-casting in return is illegal
What are the elements present in the array of the following C code?
int array[5] = {5};
5, 5, 5, 5, 5
5, 0, 0, 0, 0
5, (garbage), (garbage), (garbage), (garbage)
(garbage), (garbage), (garbage), (garbage), 5
Which keyword is used to come out of a loop only for that iteration?
break
continue
return
none of the mentioned above
