Google News
logo
C-Language - Quiz(MCQ)
1 .
Who is inventor of C Language ?
A)
James Gosling
B)
Mark Jukervich
C)
Dennis Ritchie
D)
Steve Jobs

Correct Answer :  

Dennis Ritchie

2 .
C Language initial release date ?
A)
1968
B)
1972
C)
1976
D)
1978

Correct Answer :  

1972

3 .
From the following for which opertaing systems is C language available
A)
Dos
B)
Windows
C)
Unix
D)
All of the above

Correct Answer :  

All of the above

4 .
C language is often called a ________
A)
High level language
B)
Assembly level language
C)
Low level language
D)
All of the above

Correct Answer :  

High level language

5 .
C preprocessor directive start with which of the following
A)
main()
B)
#
C)
*
D)
printf()

Correct Answer :   #

6 .
What is the only function all C programs must contain?
A)
start()
B)
system() 
C)
main()
D)
program()

Correct Answer :  

main()

7 .
Which of the following is a correct comment?
A)
*/ Comments */
B)
** Comment **
C)
/* Comment */
D)
{ Comment }

Correct Answer :  

/* Comment */ 

8 .
What object do you use to represent a file in C Language? 
A)
FILE*
B)
fopen
C)
printf
D)
fprintf

Correct Answer :  

FILE*

9 .
From the following printf() belongs to which library of c
A)
stdout.h
B)
stdio.h
C)
stdout
D)
All of the above

Correct Answer :  

stdio.h 

10 .
What punctuation ends most lines of C code?
A)
 .
B)
;
C)
:
D)

Correct Answer :  

11 .
What are the total number of keywords in C?
A)
29
B)
30
C)
32
D)
35

Correct Answer :  

32

12 .
In C int[ ] ={4,5,6,7,8} What is the value of a[3]? ?
A)
4
B)
5
C)
6
D)
7

Correct Answer :  

7

13 .
Which of the following shows the correct syntax for an if statement?
A)
if ( expression )
B)
if { expression }
C)
if expression
D)
expression if

Correct Answer :  

if ( expression )

14 .
Which of the following is the correct operator to compare two variables?
A)
:=
B)
=
C)
equal
D)
==

Correct Answer :   ==

15 .
Which of the following operators cannot be overloaded?
A)
%
B)
::
C)
+
D)
Both a and b above

Correct Answer :   ::

16 .
Which is not a loop structure?
A)
repeating
B)
do while
C)
while
D)
for

Correct Answer :  

repeating

17 .
How to read a character from the keyboard and will store it in the variable a.
A)
a = getchar( stdin );
B)
getchar( &a )
C)
a = getc();
D)
a = getchar();

Correct Answer :  

a = getchar();

18 .
Which of the following is the boolean operator for logical-and?
A)
||
B)
|
C)
&&
D)
&

Correct Answer :  

&&

19 .
By default a real number is treated as a
A)
float
B)
double
C)
long double
D)
far double

Correct Answer :  

double

20 .
int i = 2 * 3 + 4 * 5; 
Value of i:
A)
26
B)
30
C)
36
D)
40

Correct Answer :  

26

21 .
Which of the following special symbol allowed in a variable name?
A)
* (asterisk)
B)
| (pipeline)
C)
_ (underscore)
D)
- (hyphen)

Correct Answer :  

_ (underscore)

22 .
What is the size of void pointer in c ?
A)
1 byte
B)
2 byte
C)
4 byte
D)
8 byte

Correct Answer :  

2 byte 

23 .
A pointer that is pointing to nothing is called as _______ ?
A)
NULL Pointer 
B)
VOID Pointer
C)
EMPTY Pointer
D)
None of the above

Correct Answer :  

NULL Pointer 

24 .
The keyword used to transfer control from a function back to the calling function is
A)
switch
B)
goto
C)
go back
D)
return

Correct Answer :  

return

25 .
What is the return type of the function with prototype: "int func(char x, float v, double t);"
A)
char
B)
int
C)
float
D)
double

Correct Answer :  

int 

26 .
What function should be used to release allocated memory which is no longer needed?
A)
free()
B)
dealloc()
C)
release()
D)
unalloc()

Correct Answer :  

free()

27 .
What is the main difference between calloc() and malloc()?
A)
calloc() takes a single argument while malloc() needs two arguments
B)
malloc() takes a single argument while calloc() needs two arguments 
C)
malloc() initializes the allocated memory to ZERO
D)
calloc() initializes the allocated memory to NULL

Correct Answer :  

malloc() takes a single argument while calloc() needs two arguments

28 .
What is the difference between a structure and a union?
A)
We can define functions within structures but not within a union
B)
We can define functions within union but not within a structure
C)
They have no difference.
D)
The way memory is allocated

Correct Answer :  

The way memory is allocated

29 .
Which of the following is a properly defined struct?
A)
struct {int a;}
B)
struct a_struct {int a;}
C)
struct a_struct {int a;}; 
D)
struct a_struct int a; 

Correct Answer :  

struct a_struct {int a;}; 

30 .
Explain the feature of stack.
A)
stack cannot reuse its memory
B)
All operations are at one end 
C)
All elements are of different data types
D)
Any element can be accessed from it directly

Correct Answer :  

All operations are at one end 

31 .
Which of the following correctly declares an array?
A)
int anarray[9]; 
B)
int array(9);
C)
anarray{9};
D)
array anarray[9];

Correct Answer :  

int anarray[9]; 

32 .
An array is what kind of data type ?
A)
Primary
B)
Pointer 
C)
Homogenous 
D)
Heterogeneous 

Correct Answer :  

Homogenous 

33 .
Which of the following is a two-dimensional array?
A)
array anarray[20][20];
B)
int array[20, 20];
C)
char array[20];
D)
int anarray[20][20]; 

Correct Answer :  

int anarray[20][20];

34 .
Which of the following function is more appropriate for reading in a multi-word string?
A)
puts();
B)
gets(); 
C)
scanf();
D)
printf();

Correct Answer :  

gets();

35 .
In what situation, install function returns NULL?
A)
When there is no memory for adding new name
B)
When the name to be defined is already present in the table
C)
Whenever a new name is added to the table
D)
All of the mentioned

Correct Answer :  

When there is no memory for adding new name

36 .
Which of the following functions compares two strings?
A)
strcmp();
B)
stringcompare();
C)
cmp();
D)
compare();

Correct Answer :  

strcmp(); 

37 .
How will you print \n on the screen?
A)
printf("\n");
B)
echo "\\n";
C)
printf("\\n"); 
D)
printf('\n');

Correct Answer :  

printf("\\n"); 

38 .
What will be printed as the result of the operation below.
main() 
{ 
    int x=20,y=35; 
    x=y++ + x++; 
    y= ++y + ++x; 
    printf("%d%d",x,y);
}​
A)
5 8 9 4
B)
5 7 9 4 
C)
5 8 9 5
D)
5 7 8 4

Correct Answer :  

5 7 9 4 

39 .
What is the output of this C code if there is no error in stream fp?
#include <stdio.h>
 int main()
  {
     FILE *fp;
     fp = fopen("newfile", "w");
     printf("%d\n", ferror(fp));
     return 0;
  }​
A)
0
B)
1
C)
Compilation error
D)
Any nonzero value

Correct Answer :   0

40 .
Which is a valid typecast?
A)
char:a;
B)
(char)a; 
C)
a(char);
D)
to(char, a);

Correct Answer :  

(char)a;

41 .
Which of the following operators below have the highest priority when evaulating?
A)
()
B)
[]
C)
->
D)
*

Correct Answer :  

()

42 .
Which of the following can be used for random number generation?
A)
rndm()
B)
rnd()
C)
random()   
D)
None of the above

Correct Answer :  

random() 

43 .
Which of the following snippet will effectively generate random numbers?
A)
rand(); 
B)
rand(10);
C)
rand(time(NULL));
D)
All of the above

Correct Answer :  

rand();

44 .
Which of the following is true about return type of functions in C?
A)
Functions can return any type
B)
Functions can return any type except array and functions
C)
Functions can return any type except array, functions and union
D)
Functions can return any type except array, functions, function pointer and union

Correct Answer :  

Functions can return any type except array and functions 

45 .
Which of the following is a complete function?
A)
int funct(int x) {return x=x+1;}
B)
void funct(int) {printf( "Hello" ); 
C)
int funct();
D)
void funct(x) {printf( "Hello" ); }

Correct Answer :  

int funct(int x) {return x=x+1;} 

46 .
Given the following program fragment
main ()
{
 int i, j, k;
 i = 3;
 j =2*(i++);
 k =2*(++i);
}​

which one of the given option is correct?

A)
i = 4, j = 6. 
B)
i = 5, k = 6.
C)
j = 6, k = 8.
D)
j = 6, k = 10

Correct Answer :  

j = 6, k = 10.

47 .
What value of c will get printed
main()
{
	int a,b,c;
	a=10;
	b=20;
	c=printf("%d",a)+ ++b;
	printf("\n%d",c);
}​
A)
22
B)
23
C)
30
D)
None of the above

Correct Answer :   23

48 .
How many times the below loop will get executed?
main()
{
	int i;
	for(i=9;i;i=i-2)
	{
		printf("\n%d",i);
	}
}​
A)
5
B)
6
C)
7
D)
Infinite

Correct Answer :   Infinite

49 .
Is there any difference between following declarations?
int fun();
extern int fun();​
A)
No difference, except extern int fun(); is probably in another file
B)
int fun(); is overrided with extern int fun();
C)
Both are identical
D)
None of the above

Correct Answer :  

Both are identical

50 .
Which of the following statements should be used to obtain a remainder after dividing 3.14 by 2.1 ?
A)
rem = modf(3.14, 2.1);
B)
rem = fmod(3.14, 2.1); 
C)
rem = 3.14 % 2.1;
D)
rem = modf(2.1, 3.14);

Correct Answer :  

rem = fmod(3.14, 2.1); 

51 .
What will be the value of i ?
float x = 3.3;
int i;
i = (int) x;​
A)
3
B)
3.3
C)
3.0
D)
3.00

Correct Answer :  

3

52 .
Which algorithm is used for searching in the table?
A)
List search
B)
Informed search
C)
Hash search
D)
Adversarial search

Correct Answer :  

Hash search 

53 .
Is the following statement a declaration or definition?
extern int i;​
A)
Function
B)
Definition
C)
Error
D)
Declaration 

Correct Answer :  

Declaration 

54 .
Which of the following is the proper declaration of a pointer?
A)
int *x;
B)
int &x;
C)
int x;
D)
ptr x; 

Correct Answer :  

int *x; 

55 .
if (1) printf(''A''); 
 else printf(''B'');
A)
A
B)
B
C)
AB
D)
1

Correct Answer :  

56 .
for (int x=9; x>0; x/=2) 
 printf(''%d'', x);
A)
987654321 
B)
9876543210
C)
9421
D)
97531

Correct Answer :  

9421

57 .
How do we declare a float pointer?
A)
float *ptr; 
B)
*float ptr;
C)
float ptr;
D)
None of the above

Correct Answer :  

float *ptr;

58 .
What is the result of the following code?
int x=0;
switch(x)
{

  case 1: printf( "FTL" );

  case 0: printf( "FREE" );

  case 2: printf( "TIMELEARN" );

}​
A)
FTL
B)
FREE
C)
TIMELEARN
D)
FREETIMELEARN

Correct Answer :  

FREETIMELEARN

59 .
C preprocessors can have compiler specific features.
A)
true
B)
false
C)
Depends on the standard
D)
Depends on the platform

Correct Answer :  

true

60 .
In a 32-bit compiler, which 2 types have same size?
A)
char and short
B)
short and int
C)
int and float
D)
float and double

Correct Answer :  

int and float

61 .
What is the correct output from the following code?
#include <stdio.h>

int main(int argc, char** argv)
{
   int x = 3;
   printf("%d", x++  +  ++x);
   return 1;
}​
A)
5
B)
6
C)
7
D)
undefined

Correct Answer :   undefined

62 .
What is the output of the following code?
void main()
{
int i=0;
while(i++<10)
{
if(i<5 && i<9)
continue;
printf("\n%d\t",i);
}
}​
A)
1 2 3 4 5 6 7 8 9
B)
5 6 7 8 9 10
C)
5 6 7 8 9
D)
6 7 8 9 10

Correct Answer :  

5 6 7 8 9 10

63 .
What is the size of float in a 32-bit compiler?
A)
1
B)
2
C)
4
D)
8

Correct Answer :  

4

64 .
What will be the size of the following structure?
#include <stdio.h>
    struct temp
    {
        int a[10];
        char p;
    };​
A)
10
B)
30
C)
41
D)
44

Correct Answer :  

44

65 .
What is the output of this C code?
#include <stdio.h>
    union
    {
        int x;
        char y;
    }p;
    int main()
    {
        p.y = 60;
        printf("%d\n", sizeof(p));
    }​
A)
sizeof(char)
B)
sizeof(int) + sizeof(char)
C)
Depends on the compiler
D)
Compile time error

Correct Answer :  

sizeof(char)

66 .
log(x) function defined in math.h header file is
A)
Natural base logarithm
B)
Logarithm to the base 2
C)
Logarithm to the base 10
D)
None of the above

Correct Answer :  

Natural base logarithm

67 .
What is the output of this C code?
#include <stdio.h>
    int main()
    {
        int a = 4, n, i, result = 0;
        scanf("%d", n);
        for (i = 0;i < n; i++)
        result += a;
    }​
A)
Addition of a and n
B)
Subtraction of a and n
C)
Multiplication of a and n 
D)
Division of a and n

Correct Answer :  

Multiplication of a and n

68 .
What type of inputs are accepted by mathematical functions?
A)
short
B)
int
C)
float
D)
double 

Correct Answer :  

double 

69 .
In linux, apart from including math header file, the program is successfully executed by which of the following ?
A)
cc filename.c
B)
cc -lm filename.c
C)
cc -math filename.c
D)
cc filename.c -lc

Correct Answer :  

cc -lm filename.c

70 .
Which of the following is not a valid mathematical function?
A)
frexp(x);
B)
atan2(x,y);
C)
fmod(x);
D)
srand(x); 

Correct Answer :  

fmod(x); 

71 .
Predict the output of the following code segment:
// Add stdio.h header file in below code

int main()
{
int array[10] = {3, 0, 8, 1, 12, 8, 9, 2, 13, 10};
int x, y, z;
x = ++array[2];
y = array[2]++;
z = array[x++];
printf("%d %d %d", x, y, z);
return 0;
}
A)
10 9 10
B)
9 10 9
C)
9 9 10
D)
None of the above

Correct Answer :   10 9 10

72 .
Which function would you use to convert 1.98 to 1?
A)
ceil()
B)
floor()
C)
fabs()
D)
abs()

Correct Answer :   ceil()

73 .
Which of the following statements about the null pointer is correct?
A)
The null pointer is similar to an uninitialized pointer
B)
You can declare a null pointer as char* p = (char*)0
C)
The NULL macro is defined only in the stdio.h header
D)
The sizeof( NULL) operation would return the value 1

Correct Answer :   You can declare a null pointer as char* p = (char*)0

74 .
Which of the following statements about unions is incorrect?
A)
A bit field cannot be used in a union
B)
A pointer to a union exists
C)
Union elements can be of different sizes
D)
A union can be nested into a structure

Correct Answer :   A bit field cannot be used in a union

75 .
What is the range of double data type for a 16-bit compiler?
A)
-1.7e-348 to +1.7e-348
B)
-1.7e-328 to +1.7e-328
C)
-1.7e-308 to +1.7e-308
D)
None of the above

Correct Answer :   -1.7e-308 to +1.7e-308

76 .
Predict the output of the following code segment:
 
// Add stdio.h header file in below code
int main()
{
int x = 6;
int y = 4;
int z;
if(!x >= 5)
y = 3;
z = 2;
printf("%d %d", z, y);
return 0;
}
A)
4 2
B)
2 4
C)
2 3
D)
3 2

Correct Answer :   2 4

77 .
Predict the output of the following code segment:
 
// Add stdio.h header file in below code
#define PRODUCT(x) (x*x*x*x)
int main()
{
int x = 2;
int result = PRODUCT(x++);
printf("%d %d", x, result);
return 0;
}
A)
2 16
B)
3 81
C)
6 120
D)
6 1296

Correct Answer :   6 120

78 .
Predict the output of the following code segment:
 
// Add stdio.h and stdbool.h header files in below code
int main() {
bool arr[10] = { true, false };
printf( "%ld\n",sizeof(bool) );
return 0;
}
A)
1
B)
2
C)
4
D)
10

Correct Answer :   1

79 .
Predict the output of the following code segment:

// Add stdio.h header file in below code
int main()
{
const int limit = 10;
limit++;
printf("%d", limit);
return 0;
}
A)
0
B)
10
C)
11
D)
Compile error

Correct Answer :   Compile error

80 .
Predict the output of the following code segment:
 
// Add stdio.h header file in below code
int main()
{
int number1 = -17;
int number2 = -5;
int result = number1 % number2;
printf("%d",result);
return 0;
}
A)
2
B)
-2
C)
3,4
D)
-3,4

Correct Answer :   -2

81 .
Which mathematical function would you use to round off 4.23 to 5?
A)
ceil(4.23)
B)
floor(4.23)
C)
ceil(4.23, 5)
D)
floor(4.23, 5)

Correct Answer :   ceil(4.23)

82 .
Which of the following is not necessary for every C program?
A)
Header file
B)
Preprocessor directive
C)
The main function
D)
The use of a keyword

Correct Answer :   Preprocessor directive

83 .
Which of the following is the correct way to declare a function pointer where ‘pointer’ is the pointer to the function and ‘function; is the name of the function
A)
void (*pointer) = &(int)function;
B)
void function(*pointer) = int;
C)
void (*pointer)(int) = &function;
D)
void &function(*pointer) = int;

Correct Answer :   void (*pointer)(int) = &function;

84 .
Which of the following statements is true about structures and unions?
A)
The structure variable is of auto storage class by default
B)
An array of bit fields are available in both structures and unions
C)
It is necessary for all the element sizes of the union to be the same
D)
The elements of a union are always accessed with the help of ‘&’ operator

Correct Answer :   The structure variable is of auto storage class by default

85 .
Predict the output of the following segment of code: If n and p are unsigned int variables in a C program. We wish to set p to nC3. If n is large, which of the following statements is most likely to set p correctly?
A)
p = n * (n-1) * (n-2) / 6;
B)
p = n * (n-1) / 2 * (n-2) / 3;
C)
p = n * (n-1) / 3 * (n-2) / 2;
D)
p = n * (n-1) * (n-2) / 6.0;

Correct Answer :   p = n * (n-1) / 2 * (n-2) / 3;

86 .
Predict the output of the following segment of code:
 
// Add stdio.h header file in below code
int main()
{
char result = 125;
result = result + 5;
printf("%d", result);
return 0;
}
A)
130
B)
-130
C)
126
D)
-126

Correct Answer :   -126

87 .
Out of the following declarations, which one is invalid?
A)
short a = 10;
B)
unsigned short b = 20;
C)
long double c = 30;
D)
long short d = 40;

Correct Answer :   long short d = 40;

88 .
How many times freetimelearning.com is printed?

int main()
{
int a = 0;
while(a++);
{
    printf("freetimelearning.com ");
}

return 0;
}​
A)
0 time
B)
1 time
C)
Infinite times
D)
Compilation Error

Correct Answer :   1 time

89 .
C99 standard guarantees uniqueness of ____ characters for internal names.
A)
12
B)
26
C)
31
D)
48

Correct Answer :   31

90 .
Which of the following is not a valid variable name declaration?
A)
int _a3;
B)
int 3_a;
C)
int a_3;
D)
int _3a

Correct Answer :   int 3_a;


Explanation : Variable name cannot start with a digit.

91 .
What is right way to Initialization array?
A)
int num[6] = { 2, 4, 12, 5, 45, 5 } ;
B)
int n{} = { 2, 4, 12, 5, 45, 5 } ;
C)
int n{6} = { 2, 4, 12 } ;
D)
int n(6) = { 2, 4, 12, 5, 45, 5 } ;

Correct Answer :   int num[6] = { 2, 4, 12, 5, 45, 5 } ;

92 .
An array elements are always stored in _________ memory locations.
A)
Sequential
B)
Random
C)
Sequential and Random
D)
None of the above

Correct Answer :   Sequential

93 .
perror( ) function used to ?
A)
Work same as printf()
B)
prints the error message specified by the compiler
C)
prints the garbage value assigned by the compiler
D)
None of the above

Correct Answer :   prints the error message specified by the compiler

94 .
What is C Tokens?
A)
The smallest individual units of c program
B)
The basic element recognized by the compiler
C)
The largest individual units of program
D)
A & B Both

Correct Answer :   A & B Both

95 .
What is the work of break keyword?
A)
Halt execution of program
B)
Restart execution of program
C)
Exit from loop or switch statement
D)
None of the avobe

Correct Answer :   Exit from loop or switch statement

96 .
A binary tree with 27 nodes has _______ null branches.
A)
26
B)
27
C)
54
D)
None of the above

Correct Answer :   None of the above

97 .
Recursive functions are executed in a?
A)
First In First Out Order
B)
Last In First Out Order
C)
Load Balancing
D)
Parallel Fashion

Correct Answer :   Last In First Out Order

98 .
To represent hierarchical relationship between elements, which data structure is suitable?
A)
Tree
B)
Priority
C)
Dqueue
D)
All of the above

Correct Answer :   Tree

99 .
he statement printf(“%c”, 100); will print?
A)
prints 100
B)
print garbage
C)
prints ASCII equivalent of 100
D)
None of the above

Correct Answer :   prints ASCII equivalent of 100

100 .
Number of binary trees formed with 5 nodes are
A)
30
B)
36
C)
42
D)
108

Correct Answer :   42

101 .
The worst case time complexity of AVL tree is better in comparison to binary search tree for
A)
Search and Insert Operations
B)
Search and Delete Operations
C)
Insert and Delete Operations
D)
Search, Insert and Delete Operations

Correct Answer :   Search, Insert and Delete Operations

102 .
In which linked list last node address is null?
A)
Doubly linked list
B)
Circular list
C)
Singly linked list
D)
None of the above

Correct Answer :   Singly linked list

103 .
How can you make an infinite loop in C?
A)
while(1) { }
B)
loop: ... goto loop;
C)
for(;;) { }
D)
All answers are right

Correct Answer :   All answers are right

104 .
All keywords in C are in
A)
LowerCase letters
B)
UpperCase letters
C)
CamelCase letters
D)
None of the above

Correct Answer :   LowerCase letters

105 .
Which is valid C expression?
A)
int my num = 1000;
B)
int my_num = 100,000;
C)
int $my_num = 10000;
D)
int my_num = 100000;

Correct Answer :   int my_num = 100000;

106 .
Which is correct with respect to size of the datatypes?
A)
char > int > float
B)
int > char > float
C)
char < int < double
D)
double > char > int

Correct Answer :   char < int < double

107 .
Can you combine the following two statements into one?
 
char *p;
p = (char*) malloc(100);
A)
char p = *malloc(100);
B)
char *p = (char) malloc(100);
C)
char *p = (char*)malloc(100);
D)
char *p = (char *)(malloc*)(100);

Correct Answer :   char *p = (char*)malloc(100);

108 .
How many bytes are occupied by near, far and huge pointers (DOS)?
A)
near=2 far=4 huge=4
B)
near=4 far=8 huge=8
C)
near=2 far=4 huge=8
D)
near=4 far=4 huge=8

Correct Answer :   near=2 far=4 huge=4

109 .
What would be the equivalent pointer expression for referring the array element a[i][j][k][l]
A)
((((a+i)+j)+k)+l)
B)
*(*(*(*(a+i)+j)+k)+l)
C)
(((a+i)+j)+k+l)
D)
((a+i)+j+k+l)

Correct Answer :   *(*(*(*(a+i)+j)+k)+l)

110 .
What will be the output of the program ?
 
#include<stdio.h>
int main()
{
    int i=3, *j, k;
    j = &i;
    printf("%d\n", i**j*i+*j);
    return 0;
}
A)
3
B)
9
C)
27
D)
30

Correct Answer :   30

111 .
What will be the output of the program ?
 
#include<stdio.h>
int main()
{
    int x=30, *y, *z;
    y=&x; /* Assume address of x is 500 and integer is 4 byte size */
    z=y;
    *y++=*z++;
    x++;
    printf("x=%d, y=%d, z=%d\n", x, y, z);
    return 0;
}
A)
x=31, y=504, z=504
B)
x=31, y=502, z=502
C)
x=31, y=500, z=500
D)
x=31, y=498, z=498

Correct Answer :   x=31, y=504, z=504

112 .
What will be the output of the program ?
 
#include<stdio.h>
int main()
{
    char str[20] = "Hello";
    char *const p=str;
    *p='M';
    printf("%s\n", str);
    return 0;
}
A)
Mello
B)
Hello
C)
HMello
D)
MHello

Correct Answer :   Mello

113 .
What will be the output of the program If the integer is 4bytes long?
 
#include<stdio.h>
int main()
{
    int ***r, **q, *p, i=8;
    p = &i;
    q = &p;
    r = &q;
    printf("%d, %d, %d\n", *p, **q, ***r);
    return 0;
}
A)
8, 8, 8
B)
4000, 4002, 4004
C)
4000, 4004, 4008
D)
4000, 4008, 4016

Correct Answer :   8, 8, 8

114 .
What will be the output of the program if the size of pointer is 4-bytes?
 
#include<stdio.h>
int main()
{
    printf("%d, %d\n", sizeof(NULL), sizeof(""));
    return 0;
}
A)
2, 1
B)
2, 2
C)
4, 1
D)
4, 2

Correct Answer :   4, 1

115 .
What will be the output of the program assuming that the array begins at the location 1002 and size of an integer is 4 bytes?
 
#include<stdio.h>
int main()
{
    int a[3][4] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
    printf("%u, %u, %u\n", a[0]+1, *(a[0]+1), *(*(a+0)+1));
    return 0;
}
A)
520, 2, 2
B)
448, 4, 4
C)
1006, 2, 2
D)
Error

Correct Answer :   1006, 2, 2

116 .
What will be the output of the program?
 
#include<stdio.h>
int main()
{
    int arr[3] = {2, 3, 4};
    char *p;
    p = arr;
    p = (char*)((int*)(p));
    printf("%d, ", *p);
    p = (int*)(p+1);
    printf("%d", *p);
    return 0;
}
A)
0, 0
B)
2, 0
C)
2, 3
D)
2, Garbage value

Correct Answer :   2, 0

117 .
What will be the output of the program ?
 
#include<stdio.h>
int main()
{
    char *str;
    str = "%d\n";
    str++;
    str++;
    printf(str-2, 300);
    return 0;
}
A)
3
B)
30
C)
300
D)
None of the above

Correct Answer :   300

118 .
What will be the output of the program ?
 
#include<stdio.h>
int main()
{
    printf("%c\n", 7["FreeTIME"]);
    return 0;
}
A)
print "7"
B)
print "X" of FreeTIME
C)
Error: in printf
D)
Nothing will print

Correct Answer :   print "X" of FreeTIME

119 .
What will be the output of the program ?

#include<stdio.h>
power(int**);
int main()
{
    int a=5, *aa; /* Address of 'a' is 1000 */
    aa = &a;
    a = power(&aa);
    printf("%d\n", a);
    return 0;
}
power(int **ptr)
{
    int b;
    b = **ptr***ptr;
    return (b);
}​
A)
5
B)
25
C)
125
D)
Garbage value

Correct Answer :   25

120 .
What will be the output of the program ?
 
#include<stdio.h>
#include<string.h>
int main()
{
    int i, n;
    char *x="Alice";
    n = strlen(x);
    *x = x[n];
    for(i=0; i<=n; i++)
    {
        printf("%s ", x);
        x++;
    }
    printf("\n", x);
    return 0;
}
A)
Alice
B)
ecilA
C)
Alice lice ice ce e
D)
lice ice ce e

Correct Answer :   lice ice ce e

121 .
If the size of integer is 4bytes, What will be the output of the program?
 
#include<stdio.h>
int main()
{
    int arr[] = {12, 13, 14, 15, 16};
    printf("%d, %d, %d\n", sizeof(arr), sizeof(*arr), sizeof(arr[0]));
    return 0;
}
A)
10, 2, 4
B)
20, 4, 4
C)
16, 2, 2
D)
20, 2, 2

Correct Answer :   20, 4, 4

122 .
Which of the following statements correctly declare a function that receives a pointer to pointer to a pointer to a float and returns a pointer to a pointer to a pointer to a pointer to a float?
A)
float **fun(float***);
B)
float *fun(float**);
C)
float fun(float***);
D)
float ****fun(float***);

Correct Answer :   float ****fun(float***);

123 .
Which of the statements is correct about the program?
 
#include<stdio.h>
int main()
{
    int i=10;
    int *j=&i;
    return 0;
}
A)
j and i are pointers to an int
B)
i is a pointer to an int and stores address of j
C)
j is a pointer to an int and stores address of i
D)
j is a pointer to a pointer to an int and stores address of i

Correct Answer :   j is a pointer to an int and stores address of i

124 .
In the following program add a statement in the function fun() such that address of a gets stored in j?
 
#include<stdio.h>
int main()
{
    int *j;
    void fun(int**);
    fun(&j);
    return 0;
}
void fun(int **k)
{
    int a=10;
    /* Add a statement here */
}
A)
**k=a;
B)
k=&a;
C)
*k=&a
D)
&k=*a

Correct Answer :   *k=&a

125 .
Comment on the output of following code:

#include <stdio.h>
    main()
    {
        char *p = 0;
        *p = 'a';
        printf("value in pointer p is %c\n", *p);
    }​
A)
It will print a
B)
It will print 0
C)
Compile time error
D)
Run time error

Correct Answer :   Run time error

126 .
What will be the output of the following C code?
 
#include <stdio.h>
    int main()
    {
        int y = 10000;
        int y = 34;
        printf("Hello World! %d\n", y);
        return 0;
    }
A)
Hello World! 34
B)
Hello World! 1000
C)
Compile time error
D)
Hello World! followed by a junk value

Correct Answer :   Compile time error

127 .
What will be the output of the following C code?
 
#include <stdio.h>
int main(){
        int ThisIsVariableName = 12;
        int ThisIsVariablename = 14;
        printf("%d", ThisIsVariablename);
        return 0;
}
A)
The program will print 12
B)
The program will print 14
C)
The program will have a runtime error
D)
The program will cause a compile-time error due to redeclaration

Correct Answer :   The program will print 14

128 .
Which of the following cannot be a variable name in C?
A)
volatile
B)
true
C)
friend
D)
export

Correct Answer :   volatile

129 .
What will be the output of the following C code?
 
#include <stdio.h>
int main(){
        int i = 3;
        int l = i / -2;
        int k = i % -2;
        printf("%d %d\n", l, k);
        return 0;
}
A)
1 -1
B)
-1 1
C)
Implementation defined
D)
Compile time error

Correct Answer :   -1 1

130 .
What will be the final value of x in the following C code?

#include <stdio.h>
    void main()
    {
        int x = 5 * 9 / 3 + 9;
    }
A)
3
B)
3.75
C)
24
D)
Depends on compiler

Correct Answer :   24

131 .
What will be the output of the following C code?
 
    #include <stdio.h>
    void main()
    {
        int x = 0, y = 2, z = 3;
        int a = x & y | z;
        printf("%d", a);
    }
A)
0
B)
2
C)
3
D)
Run time error

Correct Answer :   3

132 .
What will be the final value of j in the following C code?
 
#include <stdio.h>
    int main()
    {
        int i = 10, j = 0;
        if (i || (j = i + 10))
            //do something
            ;
    }
A)
0
B)
20
C)
Compile time error
D)
Depends on language standard

Correct Answer :   0

133 .
What will be the output of the following C code?
 
#include <stdio.h>
int main(){
        int a = 1, b = 1, c;
        c = a++ + b;
        printf("%d, %d", a, b);
}
A)
a = 1, b = 1
B)
a = 2, b = 1
C)
a = 1, b = 2
D)
a = 2, b = 2

Correct Answer :   a = 2, b = 1

134 .
What will be the output of the following C code?

#include <stdio.h>
    int main()
    {
        int a = 10, b = 10;
        if (a = 5)
        b--;
        printf("%d, %d", a, b--);
    }​
A)
a = 10, b = 9
B)
a = 10, b = 8
C)
a = 5, b = 9
D)
a = 5, b = 8

Correct Answer :   a = 5, b = 9

135 .
What will be the output of the following C code?
 
 #include <stdio.h>
    int main()
    {
        int i = 2;
        int i = i++ + i;
        printf("%d\n", i);
    }
A)
= operator is not a sequence point
B)
++ operator may return value with or without side effects
C)
it can be evaluated as (i++)+i or i+(++i)
D)
= operator is a sequence point

Correct Answer :   = operator is not a sequence point

136 .
Comment on the output of the following C code.
 
#include <stdio.h>
    int main()
    {
        int i, n, a = 4;
        scanf("%d", &n);
        for (i = 0; i < n; i++)
            a = a * 2;
    }
A)
Logical Shift left
B)
No output
C)
Arithmetic Shift right
D)
Bitwise exclusive OR

Correct Answer :   No output

137 .
What will be the output of the following C code?
 
#include <stdio.h>
    void main()
    {
        int x = 4, y, z;
        y = --x;
        z = x--;
        printf("%d%d%d", x, y, z);
    }
A)
2 2 3
B)
2 3 3
C)
3 2 3
D)
3 2 2

Correct Answer :   2 3 3

138 .
What will be the output of the following C code?
 
#include <stdio.h>
    void main()
    {
        int x = 0;
        if (x = 0)
            printf("Its zero\n");
        else
            printf("Its not zero\n");
    }
A)
Its zero
B)
Its not zero
C)
Run time error
D)
None of the above

Correct Answer :   Its not zero

139 .
What will be the output of the following C code snippet?
 
#include <stdio.h>
    void main()
    {
        1 < 2 ? return 1: return 2;
    }
A)
Varies
B)
returns 1
C)
returns 2
D)
Compile time error

Correct Answer :   Compile time error

140 .
What will be the output of the following C code?
 
#include <stdio.h>
    int main()
    {
        int x = 2, y = 2;
        x /= x / y;
        printf("%d\n", x);
        return 0;
    }
A)
0.5
B)
1
C)
2
D)
None of the above

Correct Answer :   2

141 .
What will be the output of the following C code?
 
#include <stdio.h>
    int main()
    {
        int x = 1;
        int y =  x == 1 ? getchar(): 2;
        printf("%d\n", y);
    }
A)
Ascii value of character getchar function returns
B)
Whatever character getchar function returns
C)
Compile time error
D)
None of the above

Correct Answer :   Ascii value of character getchar function returns

142 .
What will be the output of the following C code?
 
#include <stdio.h>
    int main()
    {
        int a = 2;
        int b = 0;
        int y = (b == 0) ? a :(a > b) ? (b = 1): a;
        printf("%d\n", y);
    }
A)
1
B)
2
C)
Compile time error
D)
Undefined behaviour

Correct Answer :   2

143 .
What will be the output of the following C code?
 
#include <stdio.h>
    void main()
    {
        int k = 8;
        int m = 7;
        int z = k < m ? k = m : m++;
        printf("%d", z);
    }
A)
7
B)
8
C)
Run time error
D)
Depends on compiler

Correct Answer :   7

144 .
What will be the output of the following C code?
 
#include <stdio.h>
    int main()
    {
        int x = 2, y = 0;
        int z = y && (y |= 10);
        printf("%d\n", z);
        return 0;
    }
A)
2
B)
1
C)
0
D)
None of the above

Correct Answer :   0

145 .
What will be the output of the following C code?
 
#include <stdio.h>
    int main()
    {
        int y = 2;
        int z = y +(y = 10);
        printf("%d\n", z);
    }
A)
4
B)
12
C)
20
D)
Either 12 or 20

Correct Answer :   20

146 .
Which of the following are unary operators?
A)
-
B)
++
C)
sizeof
D)
all of the mentioned

Correct Answer :   all of the mentioned

147 .
Which of the following method is accepted for assignment?
A)
5 = a = b = c = d;
B)
a = b = c = d = 5;
C)
a = b = 5 = c = d;
D)
None of the above

Correct Answer :   a = b = c = d = 5;

148 .
Which of the following is possible with any 2 operators in C?
A)
Same associativity, different precedence
B)
Same associativity, same precedence
C)
Different associativity, different precedence
D)
All of the mentioned

Correct Answer :   All of the mentioned

149 .
What will be the output of the following C code?

#include <stdio.h>
    void main()
    {
        int x = 5;
        if (true);
            printf("hello");
    }​
A)
It will display hello
B)
It will throw an error
C)
Nothing will be displayed
D)
Compiler dependent

Correct Answer :   It will throw an error

150 .
What will be the output of the following C code?
 
#include <stdio.h>
    void main()
    {
        int x = 0;
        if (x == 0)
            printf("hi");
        else
            printf("how are u");
            printf("hello");
    }
A)
hi
B)
hello
C)
hihello
D)
how are you

Correct Answer :   hihello

151 .
What will be the output of the following C code? (Assuming that we have entered the value 1 in the standard input)
 
#include <stdio.h>
    void main()
    {
        int ch;
        printf("enter a value between 1 to 2:");
        scanf("%d", &ch);
        switch (ch, ch + 1)
        {
           case 1:
              printf("1\n");
              break;
           case 2:
              printf("2");
              break;
        }
    }
A)
1
B)
2
C)
3
D)
Run time error

Correct Answer :   2

152 .
The C code ‘for(;;)’ represents an infinite loop. It can be terminated by _______
A)
break
B)
exit(0)
C)
abort()
D)
terminate

Correct Answer :   break

153 .
Which for loop has range of similar indexes of ‘i’ used in for (i = 0;i < n; i++)?
A)
for (i = n; i>0; i–)
B)
for (i = n; i >= 0; i–)
C)
for (i = n-1; i>0; i–)
D)
for (i = n-1; i>-1; i–)

Correct Answer :   for (i = n-1; i>-1; i–)

154 .
What will be the output of the following C code?
 
#include <stdio.h>
    void main()
    {
        double k = 0;
        for (k = 0.0; k < 3.0; k++)
            printf("Hello");
    }
A)
Run time error
B)
Hello is printed thrice
C)
Hello is printed twice
D)
Hello is printed infinitely

Correct Answer :   Hello is printed thrice

155 .
What will be the output of the following C code?
 
#include <stdio.h>
    int main()
    {
        while ()
            printf("In while loop ");
        printf("After loop\n");
    }
A)
After loop
B)
Infinite loop
C)
In while loop after loop
D)
Compile time error

Correct Answer :   Compile time error

156 .
fseek() should be preferred over rewind() mainly because
A)
rewind() doesn't work for empty files
B)
rewind() may fail for large files
C)
In rewind, there is no way to check if the operations completed successfully
D)
All of the above

Correct Answer :   In rewind, there is no way to check if the operations completed successfully

157 .
How many times does the loop run?
 
#include <stdio.h> 
int main() 
{ 
    int i; 
    for (i = 1; i <= 100; i++) { 
        printf("GFG\n"); 
        if (i == 5) 
            break; 
    } 
    return (0); 
} 
A)
5 times
B)
10 times
C)
15 times
D)
20 times

Correct Answer :   5 times

158 .
what will be the output?
 
#include <stdio.h> 
int main() 
{ 
    int i; 
    for (i = 1; i <= 10; i++) { 
        printf("welcome\n"); 
        continue; 
        printf("hii"); 
    } 
    return (0); 
}
A)
print hii 5 times
B)
print hii 10 times
C)
print welcome 5 times
D)
print welcome 10 times

Correct Answer :   print welcome 10 times

159 .
Which of the above three functions are likely to cause problems with pointers?
A)
Only P3
B)
Only P1 and P3
C)
Only P1 and P2
D)
P1, P2 and P3

Correct Answer :   Only P1 and P2

160 .
What is the return type of malloc() or calloc()
A)
void *
B)
void **
C)
int *
D)
Pointer of allocated memory type

Correct Answer :   void *

161 .
Which of the following is true?
A)
"ptr = calloc(m, n)" is equivalent to following
ptr = malloc(m * n);
B)
"ptr = calloc(m, n)" is equivalent to following
ptr = malloc(m * n); memset(ptr, 0, m * n);
C)
"ptr = calloc(m, n)" is equivalent to following
ptr = malloc(m); memset(ptr, 0, m);
D)
"ptr = calloc(m, n)" is equivalent to following
ptr = malloc(n); memset(ptr, 0, n);

Correct Answer :  

"ptr = calloc(m, n)" is equivalent to following
ptr = malloc(m * n); memset(ptr, 0, m * n);

162 .
Consider the following variable declarations and definitions in C
i) int var_9 = 1;
ii) int 9_var = 2;
iii) int _ = 3;
 
Choose the correct statement w.r.t. above variables.
A)
Both i) and iii) are valid.
B)
Only i) is valid.
C)
Both i) and ii) are valid.
D)
All are valid.

Correct Answer :   Both i) and iii) are valid.

163 .
What is the output of the below program?
#include <stdio.h>
int main()
{
    int i = 0;
    switch (i)
    {
        case '0': printf("Free");
                break;
        case '1': printf("Time");
                break;
        default: printf("FreeQuiz");
    }
    return 0;
}​
 
A)
Free
B)
Time
C)
FreeQuiz
D)
Compile-time error

Correct Answer :   FreeQuiz

164 .
Predict the output of the below program:
#include <stdio.h>
#define EVEN 0
#define ODD 1
int main()
{
    int i = 3;
    switch (i & 1)
    {
        case EVEN: printf("Even");
                break;
        case ODD: printf("Odd");
                break;
        default: printf("Default");
    }
    return 0;
}
A)
Even
B)
Odd
C)
Default
D)
Compile-time error

Correct Answer :   Odd

165 .
Consider the following C declaration

struct { 
    short s[5];
    union { 
         float y; 
         long z; 
    }u; 
} t;
 
Assume that objects of the type short, float and long occupy 2 bytes, 4 bytes and 8 bytes, respectively. The memory requirement for variable t, ignoring alignment considerations, is :
A)
10 bytes
B)
14 bytes
C)
18 bytes
D)
22 bytes

Correct Answer :   18 bytes

166 .
What will be the output of the following C code?
 
   #include <stdio.h>
    int i;
    int main()
    {
        extern int i;
        if (i == 0)
            printf("scope rules\n");
    }
A)
scope rules
B)
Compile time error due to multiple declaration
C)
Compile time error due to not defining type in statement extern i
D)
Compile time error due to not defining type in statement extern i

Correct Answer :   scope rules

167 .
What will be the output of the following C code (after linking to source file having definition of ary1)?
 
   #include <stdio.h>
    int main()
    {
        extern ary1[];
        printf("%d\n", ary1[0]);
    }
A)
Value of ary1[0];
B)
Compile time error due to multiple definition
C)
Compile time error because size of array is not provided
D)
Compile time error because datatype of array is not provided

Correct Answer :   Compile time error because datatype of array is not provided

168 .
What is the scope of an external variable?
A)
Whole source file in which it is defined
B)
From the point of declaration to the end of the file in which it is defined
C)
Any source file in a program
D)
From the point of declaration to the end of the file being compiled

Correct Answer :   From the point of declaration to the end of the file being compiled

169 .
Comment on the output of the following C code.
 
    #include <stdio.h>
    int main()
    {
        int i;
        for (i = 0;i < 5; i++)
        int a = i;
        printf("%d", a);
    }
A)
a is out of scope when printf is called
B)
Redeclaration of a in same scope throws error
C)
Syntax error in declaration of a
D)
No errors, program will show the output 5

Correct Answer :   Syntax error in declaration of a

170 .
What will be the output of the following C code?
 
    #include <stdio.h>
    #define foo(m, n) m ## n
    int main()
    {
        printf("%s\n", foo(k, l));
    }
A)
k l
B)
kl
C)
Compile time error
D)
Undefined behaviour

Correct Answer :   Compile time error

171 .
What will be the output of the following C code?
 
    #include <stdio.h>
    #define foo(x, y) x / y + x
    int main()
    {
        int i = -6, j = 3;
        printf("%d\n",foo(i + j, 3));
        return 0;
    }
A)
-4
B)
-8
C)
Compile time error
D)
Divided by zero exception

Correct Answer :   -8

172 .
What will be the output of the following C code?
 
    #include <stdio.h>
    #define foo(x, y) x / y + x
    int main()
    {
        int i = -6, j = 3;
        printf("%d ", foo(i + j, 3));
        printf("%d\n", foo(-3, 3));
        return 0;
    }
A)
-4 -4
B)
-8 -4
C)
-4 divided by zero exception
D)
Divided by zero exception

Correct Answer :   -8 -4

173 .
What is the advantage of #define over const?
A)
Data type is flexible
B)
Can have a pointer
C)
Reduction in the size of the program
D)
None of the mentioned

Correct Answer :   Data type is flexible

174 .
What is #include <stdio.h>?
A)
Preprocessor directive
B)
Inclusion directive
C)
File inclusion directive
D)
None of the mentioned

Correct Answer :   Preprocessor directive

175 .
C preprocessors can have compiler specific features.
A)
True
B)
False
C)
Depends on the standard
D)
Depends on the platform

Correct Answer :   True

176 .
Preprocessor feature that supply line numbers and filenames to compiler is called?
A)
Line control
B)
Concatenation
C)
Selective inclusion
D)
macro substitution

Correct Answer :   Line control

177 .
#include <somefile.h> are _______ files and #include “somefile.h” ________ files.
A)
Library, Library
B)
Library, user-created header
C)
User-created header, library
D)
They can include all types of file

Correct Answer :   They can include all types of file

178 .
The “else if” in conditional inclusion is written by?
A)
#else if
B)
#elseif
C)
#elsif
D)
#elif

Correct Answer :   #elif

179 .
In a conditional inclusion, if the condition that comes after the if is true, then what will happen during compilation?
A)
Then the code up to the following #else or #elif or #endif is compiled
B)
Then the code up to the following #endif is compiled even if #else or #elif is present
C)
Then the code up to the following #eliif is compiled
D)
None of the above

Correct Answer :   Then the code up to the following #else or #elif or #endif is compiled

180 .
Conditional inclusion can be used for _______
A)
Preventing multiple declarations of a variable
B)
Check for existence of a variable and doing something if it exists
C)
Preventing multiple declarations of same function
D)
All of the mentioned

Correct Answer :   All of the mentioned

181 .
What will be the output of the following C code?
 
    #include <stdio.h>
    int x;
    void main()
    {
        printf("%d", x);
    }
A)
0
B)
Junk value
C)
Run time error
D)
Undefined

Correct Answer :   0

182 .
Functions in C are always ___
A)
Internal
B)
External
C)
Both Internal and External
D)
External and Internal are not valid terms for functions

Correct Answer :   External

183 .
Global variables are _______
A)
Internal
B)
External
C)
Both Internal and External
D)
None of the above

Correct Answer :   External

184 .
What will be the output of the following C code?
 
    #include <stdio.h>
    int main()
    {
        printf("%d", d++);
    }
    int d = 10;
A)
9
B)
10
C)
11
D)
Compile time error

Correct Answer :   Compile time error

185 .
What is the return-type of the function sqrt()?
A)
int
B)
float
C)
double
D)
depends on the data type of the parameter

Correct Answer :   double

186 .
What will be the data type returned for the following C function?
 
    #include <stdio.h>
    int func()
    {
        return (double)(char)5.0;
    }
A)
char
B)
int
C)
double
D)
multiple type-casting in return is illegal

Correct Answer :   int

187 .
What is the problem in the following C declarations?
 
 int func(int);
 double func(int);
 int func(float);
A)
A function with same name cannot have different signatures
B)
A function with same name cannot have different signatures
C)
A function with same name cannot have different number of parameters
D)
All of the mentioned

Correct Answer :   All of the mentioned

188 .
Comment on the following C statement.

int (*a)[7];​
A)
An array “a” of pointers
B)
A pointer “a” to an array
C)
A ragged array
D)
None of the above

Correct Answer :   A pointer “a” to an array

189 .
Comment on the following 2 arrays with respect to P and Q.
 
   int *a1[8];
   int *(a2[8]);
   P. Array of pointers
   Q. Pointer to an array
A)
a1 is P, a2 is Q
B)
a1 is Q, a2 is Q
C)
a1 is P, a2 is P
D)
a1 is Q, a2 is P

Correct Answer :   a1 is P, a2 is P

190 .
Which of the following is not possible statically in C?
A)
Jagged Array
B)
Rectangular Array
C)
Cuboidal Array
D)
Multidimensional Array

Correct Answer :   Jagged Array

191 .
What will be the output of the following C code?
 
    #include <stdio.h>
    int main()
    {
        double *ptr = (double *)100;
        ptr = ptr + 2;
        printf("%u", ptr);
    }
A)
102
B)
104
C)
108
D)
116

Correct Answer :   116

192 .
Which of the following arithmetic operation can be applied to pointers a and b?
(Assuming initialization as int *a = (int *)2; int *b = (int *)3;)
A)
a + b
B)
a – b
C)
a * b
D)
a / b

Correct Answer :   a – b

193 .
Which of following logical operation can be applied to pointers?
(Assuming initialization int *a = 2; int *b = 3;)
A)
a | b
B)
a ^ b
C)
a & b
D)
None of the above

Correct Answer :   None of the above

194 .
What will be the output of the following C code?
 
    #include <stdio.h>
    void main()
    {
        char *s = "hello";
        char *p = s;
        printf("%c\t%c", *p, s[1]);
    }
A)
e h
B)
h h
C)
h e
D)
Compile time error

Correct Answer :   h e

195 .
What will be the output of the following C code?
 
    #include <stdio.h>
    int main()
    {
        char *str = "hello, world\n";
        char *strc = "good morning\n";
        strcpy(strc, str);
        printf("%s\n", strc);
        return 0;
    }
A)
hello, world
B)
Run time error
C)
Undefined behaviour
D)
Crash/segmentation fault

Correct Answer :   Crash/segmentation fault

196 .
What will be the output of the following C code?
 
    #include <stdio.h>
    int main()
    {
        char str[] = "hello, world";
        str[5] = '.';
        printf("%s\n", str);
        return 0;
    }
A)
hello. world
B)
hello, world
C)
Compile error
D)
Segmentation fault

Correct Answer :   hello. world

197 .
What will be the output of the following C code?
 
    #include <stdio.h>
    int main()
    {
        char *str = "hello world";
        char strary[] = "hello world";
        printf("%d %d\n", strlen(str), strlen(strary));
        return 0;
    }
A)
11 11
B)
12 11
C)
11 12
D)
x 11 where x can be any positive integer.

Correct Answer :   11 11

198 .
What will be the output of the following C code?
 
    #include <stdio.h>
    void fun(char *k)
    {
        printf("%s", k);
    }
    void main()
    {
        char s[] = "hello";
        fun(s);
    }
A)
hello
B)
h
C)
Nothing
D)
Run time error

Correct Answer :   hello

199 .
What will be the output of the following C code?
 
    #include <stdio.h>
    int main()
    {
        int a = 1, b = 2, c = 3;
        int *ptr1 = &a, *ptr2 = &b, *ptr3 = &c;
        int **sptr = &ptr1; //-Ref
        *sptr = ptr2;
    }
A)
ptr1 points to a
B)
ptr1 points to b
C)
sptr points to ptr2
D)
None of the above

Correct Answer :   ptr1 points to b

200 .
Which is true for a, if a is defined as “int a[10][20];”?
A)
a is true two-dimensional array
B)
200 int-sized locations have been set aside
C)
The conventional rectangular subscript calculation 20 * row + col is used to find the element a[row, col].
D)
All of the above

Correct Answer :   All of the above

201 .
Which is true for b, if b is defined as “int *b[10];”?
A)
The definition only allocates 10 pointers and does not initialize them
B)
Initialization must be done explicitly
C)
The definition only allocates 10 pointers and does not initialize them & Initialization must be done explicitly
D)
Error

Correct Answer :   The definition only allocates 10 pointers and does not initialize them & Initialization must be done explicitly

202 .
What will be the output of the following C code?
 
    #include <stdio.h>
    void main()
    {
        char a[10][5] = {"hi", "hello", "fellows"};
        printf("%d", sizeof(a[1]));
    }
A)
2
B)
4
C)
5
D)
10

Correct Answer :   5

203 .
What will be the output of the following C code?
 
    #include <stdio.h>
    int main()
    {
        char a[1][5] = {"hello"};
        printf("%s", a[0]);
        return 0;
    }
A)
hello
B)
hellon
C)
Compile time error
D)
Undefined behaviour

Correct Answer :   Undefined behaviour

204 .
What will be the output of the following C code?
 
    #include <stdio.h>
    int main()
    {
        char *a[1] = {"hello"};
        printf("%s", a[0]);
        return 0;
    }
A)
hello
B)
hellon
C)
Compile time error
D)
Undefined behaviour

Correct Answer :   hello

205 .
Which of the following statements are true?
 
    P. Pointer to Array
    Q. Multi-dimensional array

A)
P are static, Q are static
B)
P are static, Q are dynamic
C)
P are dynamic, Q are static
D)
P are dynamic, Q are dynamic

Correct Answer :   P are dynamic, Q are static

206 .
What does argc and argv indicate in command-line arguments?
(Assuming: int main(int argc, char *argv[]) )
A)
argument count, argument variable
B)
argument count, argument vector
C)
argument control, argument variable
D)
argument control, argument vector

Correct Answer :   argument count, argument vector

207 .
In linux, argv[0] by command-line argument can be occupied by _____
A)
./a.out
B)
./test
C)
./fun.out.out
D)
all of the mentioned

Correct Answer :   all of the mentioned

208 .
What type of array is generally generated in Command-line argument?
A)
Single dimension array
B)
2-Dimensional Square Array
C)
2-Dimensional Rectangular Array
D)
Jagged Array

Correct Answer :   Jagged Array

209 .
What is the second argument in command line arguments?
A)
The number of command-line arguments the program was invoked with;
B)
A pointer to an array of character strings that contain the arguments, one per string
C)
Nothing
D)
None of the above

Correct Answer :   A pointer to an array of character strings that contain the arguments, one per string

210 .
What is argv[0] in command line arguments?
A)
The name by which the program was invoked
B)
The name of the files which are passed to the program
C)
Count of the arguments in argv[] vector
D)
None of the above

Correct Answer :   The name by which the program was invoked

211 .
Which of the following is a correct syntax to pass a Function Pointer as an argument?
A)
void pass(int (*fptr)(int, float, char)){}
B)
void pass(*fptr(int, float, char)){}
C)
void pass(int (*fptr)){}
D)
void pass(*fptr){}

Correct Answer :   void pass(int (*fptr)(int, float, char)){}

212 .
What will be the output of the following C code?
 
    #include <stdio.h>
    void first()
    {
        printf("Hello World");
    }
    void main()
    {
        void *ptr() = first;
        ptr++
        ptr();
    }
A)
Illegal application of ++ to void data type
B)
pointer function initialized like a variable
C)
Illegal application of ++ to void data type & pointer function initialized like a variable
D)
None of the above

Correct Answer :   Illegal application of ++ to void data type & pointer function initialized like a variable

213 .
What will be the output of the following C code?
 
    #include <stdio.h>
    void f(int (*x)(int));
    int myfoo(int);
    int (*fooptr)(int);
    int ((*foo(int)))(int);
    int main()
    {
        fooptr = foo(0);
        fooptr(10);
    }
    int ((*foo(int i)))(int)
    {
        return myfoo;
    }
    int myfoo(int i)
    {
        printf("%d\n", i + 1);
    }
A)
10
B)
11
C)
Compile time error
D)
Undefined behaviour

Correct Answer :   11

214 .
What will be the output of the following C code?
 
    #include <stdio.h>
    struct student
    {
        int no = 5;
        char name[20];
    };
    void main()
    {
        struct student s;
        s.no = 8;
        printf("hello");
    }
A)
Nothing
B)
Varies
C)
hello
D)
Compile time error

Correct Answer :   Compile time error

215 .
What does this declaration say?
 
int (*(*y)())[2];
A)
y is pointer to the function which returns pointer to integer array
B)
y is pointer to the function which returns array of pointers
C)
y is function which returns function pointer which in turn returns pointer to integer array
D)
y is function which returns array of integers

Correct Answer :   y is pointer to the function which returns pointer to integer array

216 .
Which of the following are themselves a collection of different data types?
A)
string
B)
structures
C)
char
D)
all of the mentioned

Correct Answer :   structures

217 .
Which of the following cannot be a structure member?
A)
Another structure
B)
Function
C)
Array
D)
None of the above

Correct Answer :   Function

218 .
What will be the output of the following C code?
 
    #include <stdio.h>
    struct student
    {
        int no;
        char name[20];
    }
    void main()
    {
        struct student s;
        s.no = 8;
        printf("hello");
    }
A)
hello
B)
Varies
C)
Nothing
D)
Compile time error

Correct Answer :   Compile time error

219 .
What will be the output of the following C code?
 
    #include <stdio.h>
    void main()
    {
        struct student
        {
            int no;
            char name[20];
        };
        struct student s;
        s.no = 8;
        printf("%d", s.no);
    }
A)
8
B)
Junk
C)
Nothing
D)
Compile time error

Correct Answer :   8

220 .
What will be the output of the following C code?
 
    #include <stdio.h>
    struct student
    {
        char *name;
    };
    void main()
    {
        struct student s, m;
        s.name = "st";
        m = s;
        printf("%s%s", s.name, m.name);
    }
A)
st st
B)
Junk values
C)
Nothing
D)
Compile time error

Correct Answer :   st st

221 .
Which of the following is not possible under any scenario?
A)
s1 = &s2;
B)
s1 = s2;
C)
(*s1).number = 10;
D)
None of the mentioned

Correct Answer :   None of the mentioned

222 .
Which of the following operation is illegal in structures?
A)
Typecasting of structure
B)
Pointer to a variable of the same structure
C)
Dynamic allocation of memory for structure
D)
All of the mentioned

Correct Answer :   Typecasting of structure

223 .
Presence of code like “s.t.b = 10” indicates __________
A)
Syntax Error
B)
Structure
C)
double data type
D)
An ordinary variable name

Correct Answer :   Structure

224 .
What will be the output of the following C code?
 
    #include <stdio.h>
    struct p
    {
        int x;
        char y;
    };
    typedef struct p* q*;
    int main()
    {
        struct p p1[] = {1, 92, 3, 94, 5, 96};
        q ptr1 = p1;
        printf("%d\n", ptr1->x);
    }
A)
1
B)
Segmentation fault
C)
Compile time error
D)
Undefined behaviour

Correct Answer :   Compile time error

225 .
Which of the following is an incorrect syntax for pointer to structure?
 
(Assuming struct temp{int b;}*my_struct;)
 
A)
*my_struct.b = 10;
B)
(*my_struct).b = 10;
C)
my_struct->b = 10;
D)
Both *my_struct.b = 10; and (*my_struct).b = 10;

Correct Answer :   *my_struct.b = 10;

226 .
Which of the following is an incorrect syntax to pass by reference a member of a structure in a function?

(Assume: struct temp{int a;}s;)
A)
func(&s.a);
B)
func(&(s).a);
C)
func(&(s.a));
D)
None of the mentioned

Correct Answer :   None of the mentioned

227 .
Which option is not possible for the following function call?
 
func(&s.a); //where s is a variable of type struct and a is the member of the struct.
 
A)
Compiler can access entire structure from the function
B)
Individual member’s address can be displayed in structure
C)
Individual member can be passed by reference in a function
D)
None of the mentioned

Correct Answer :   Compiler can access entire structure from the function

228 .
Which member of the union will be active after REF LINE in the following C code?
 
    #include <stdio.h>
    union temp
    {
        int a;
        float b;
        char c;
    };
    union temp s = {1,2.5,’A’}; //REF LINE
A)
a
B)
b
C)
c
D)
Such declaration are illegal

Correct Answer :   a

229 .
What type of data is holded by variable u int in the following C code?
 
    #include <stdio.h>
    union u_tag
    {
        int ival;
        float fval;
        char *sval;
    } u;
A)
Will be large enough to hold the largest of the three types;
B)
Will be large enough to hold the smallest of the three types;
C)
Will be large enough to hold the all of the three types;
D)
None of the mentioned

Correct Answer :   Will be large enough to hold the largest of the three types;

230 .
In the following C code, we can access the 1st character of the string sval by using _______
 
    #include <stdio.h>
    struct
    {
        char *name;
        union
        {
            char *sval;
        } u;
    } symtab[10];
A)
*symtab[i].u.sval
B)
symtab[i].u.sval[0].
C)
You cannot have union inside structure
D)
Both *symtab[i].u.sval & symtab[i].u.sval[0].

Correct Answer :   Both *symtab[i].u.sval & symtab[i].u.sval[0].

231 .
What will be the output of the following C code?
 
    #include <stdio.h>
    struct student
    {
        char a[5];
    };
    void main()
    {
        struct student s[] = {"hi", "hey"};
        printf("%c", s[0].a[1]);
    }
A)
h
B)
i
C)
e
D)
y

Correct Answer :   i

232 .
What will be the output of the following C code?
 
    #include <stdio.h>
    void main()
    {
        int lookup[100] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
        printf("%d", lookup[3]);
    }
A)
2
B)
3
C)
4
D)
Compile time error

Correct Answer :   3

233 .
Which among the following is the odd one out?
A)
printf
B)
fprintf
C)
putchar
D)
scanf

Correct Answer :   scanf

234 .
What is the use of getchar()?
A)
The next input character each time it is called
B)
EOF when it encounters end of file
C)
The next input character each time it is called EOF when it encounters end of file
D)
None of the mentioned

Correct Answer :   The next input character each time it is called EOF when it encounters end of file

235 .
What is the return value of putchar()?
A)
The character written
B)
EOF if an error occurs
C)
Nothing
D)
Both character written & EOF if an error occurs

Correct Answer :   Both character written & EOF if an error occurs

236 .
Which of the following statement is true?
A)
The symbolic constant EOF is defined in <stdio.h>
B)
The value is -1
C)
The symbolic constant EOF is defined in <stdio.h> & value is -1
D)
Only value is -1

Correct Answer :   The symbolic constant EOF is defined in <stdio.h> & value is -1

237 .
What will be the output of the following C code?
 
    #include <stdio.h>
    int main()
    {
        int i = 10, j = 2;
        printf("%d\n", printf("%d %d ", i, j));
    }
A)
10 2 4
B)
10 2 2
C)
10 2 5
D)
Compile time error

Correct Answer :   10 2 5

238 .
What will be the output of the following C code?
 
    #include <stdio.h>
    int main()
    {
        int i = 10, j = 3;
        printf("%d %d %d", i, j);
    }
A)
10 3
B)
10 3 some garbage value
C)
Compile time error
D)
Undefined behaviour

Correct Answer :   10 3 some garbage value

239 .