NO.
QUESTION What will be output of the following program? #include<stdio.h> int main(){ int x; x=10,20,30; printf("%d",x); return 0; }
10 2 In which stage the following code #include<stdio.h> gets replaced by the contents of the file stdio.h
During editing
Which of the following function sets first n characters of a string to a given character? strinit()
4 If the two strings are identical, then strcmp() function
returns -1
5 How will you print \n on the screen? 6 The library function used to find the last occurrence of a character in a string is Which of the following function is used to find the first occurrence of a given string in another string?
printf("\n");
strnstr()
strchr()
Which of the following function is more appropriate for reading in a multi-word string? What will be the output of the program ? #include<stdio.h> #include<string.h> int main() { char str1[20] = "Hello", str2[20] = " World"; printf("%s\n", strcpy(str2, strcat(str1, str2))); return 0;
printf();
Hello
What will be the output of the program ? #include<stdio.h> int main() { char p[] = "%d\n"; p[1] = 'c'; printf(p, 65); What will0; be the output of the program ? return #include<stdio.h> #include<string.h> int main() { printf("%d\n", strlen("123456")); return 0; } 6 What will be the output of the program ? #include<stdio.h> int main() { printf(5+"Good Morning\n"); return 0; } Good Morning What will be the output of the program If characters 'a', 'b' and 'c' enter are supplied as input? #include<stdio.h> 13 int main() { void fun(); fun(); printf("\n"); What will be the output of the program ? #include<stdio.h> int main() { printf("India", "BIX\n"); return 0; } Error
10
11
12
abc abc
14
What will be the output of the program ? #include<stdio.h> int main() { char *names[] = { "Suresh", "Siva", "Sona", "Baiju", "Ritu"}; int i; char *t; What will be output of the following program? #include<stdio.h> int main(){ float a=0.7; if(a<0.7){ printf("C"); } else{ printf("C++");
15
Suresh, Siva, Sona, Baiju, Ritu
16
17
What is meaning of following declaration? int(*ptr[5])(); ptr is pointer to function What will be the output of the program ? #include<stdio.h> int main() { static char mess[6][30] = {"Don't walk in front of me...", "I may not follow;", "Don't walk behind me...", "Just walk beside me...", "And be my friend." }; printf("%c, %c\n", *(mess[2]+9), *(*(mess+2)+9)); return 0;
18
t, t
19 What are the different types of real data type in C ? float, double
20
Which statement will you add in the following program to work it correctly? #include<stdio.h> int main() { printf("%f\n", log(36.0)); return 0; } #include<conio.h>
21 The binary equivalent of 5.375 is 22 What will you do to treat the constant 3.14 as a float? What will be the output of the program? #include<stdio.h> int main() { float a=0.7; if(a < 0.7) printf("C\n"); else printf("C++\n"); return 0; } C What will be the output of the program? #include<stdio.h> #include<math.h> int main() { printf("%f\n", sqrt(36.0)); return 0; } . What will be the output of the program? #include<stdio.h> #include<math.h> int main() { printf("%d, %d, %d\n", sizeof(3.14f), sizeof(3.14), sizeof(3.14l)); return 0; } 4, 4, 4 use float(3.14f) 101.1011101
23
24
25
26
What will be the output of the program? #include<stdio.h> #include<math.h> int main() { float n=1.54; printf("%f, %f\n", ceil(n), floor(n)); return 0; } 2.000000, 1.000000
27 What is (void*)0? 28
Representation of NULL pointer
Can you combine the following two statements into one? char p = *malloc(100); 29 In which header file is the NULL macro defined? stdio.h
30
. If a variable is a pointer to a structure, then which of the following operator is used to access data members of the structure through the pointer variable? .
31 What would be the equivalent pointer expression for referring the array elementa[i][j][k][l] 32 A pointer is ((((a+i)+j)+k)+l) A keyword used to create variables
33 The operator used to get value at address stored in a pointer variable is *
What will be the output of the program ? #include<stdio.h> int main() { static char *s[] = {"black", "white", "pink", "violet"}; char **ptr[] = {s+3, s+2, s+1, s}, ***p; p = ptr; ++p; printf("%s", **p+1); return 0; } . 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; } 30 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++; What will be the output of the program ? #include<stdio.h> int main() { char *str; str = "%s"; printf(str, "K\n"); return 0; } Error ink
34
35
36
x=31, y=502, z=502
37
. 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; } 10, 2, 4 Point out the compile time error in the program given below. #include<stdio.h> 39 int main() { int *x; *x=100; return 0;
38
Error: invalid assignment for x
40
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? float **fun(float***); Which of the following statements correct about k used in the below statement? char ****k; k is a pointer to a pointer Which of the statements is correct about the program? to a pointer to a char #include<stdio.h> int main() { int arr[3][3] = {1, 2, 3, 4}; printf("%d\n", *(*(*(arr)))); return 0; } Output: Garbage value
41
42
43 How will you free the allocated memory ? remove(var-name);
44 What is the similarity between a structure, union and What will be the output of the program ? enumeration? #include<stdio.h> int main() { enum days {MON=-1, TUE, WED=6, THU, FRI, SAT}; printf("%d, %d, %d, %d, %d, %d\n", MON, TUE, WED, THU, FRI, SAT); return 0; } -1, 0, 1, 2, 3, 4 What will be the output of the program ? #include<stdio.h> int main() { enum days {MON=-1, TUE, WED=6, THU, FRI, SAT}; printf("%d, %d, %d, %d, %d, %d\n", ++MON, TUE, WED, THU, FRI, SAT); return 0; } -1, 0, 1, 2, 3, 4 Reposition the file pointer to a character reverse All of them let you define new values
45
46
47 What will the function rewind() do?
48 Input/output function prototypes and macros are defined in which header file? conio.h
49
Input/output function prototypes and macros are defined in which header file? conio.h
50
Which standard library function will you use to find the last occurance of a character in a string in C? strnchar()
51 What is stderr ? 52 What is the purpose of fflush() function 53 standard error
flushes all streams and specified streams
What will the function randomize() do in Turbo C under DOS? will be the output of the program? What #include<stdio.h> int main() { int i; i = printf("How r u\n"); i = printf("%d\n", i); printf("%d\n", i); return 0; } What will be the output of the program? #include<stdio.h> int main() { int i; i = scanf("%d %d", &i, &i); printf("%d\n", i); return 0; }
returns a random number
54
How r u 7 2
55
56 What will function gcvt() do? Convert vector to integer value
What will be the output of the program? #include<stdio.h> int main() { int i; char c; for(i=1; i<=5; i++) { scanf("%c", &c); /* given input is 'a' */ printf("%c", c); ungetc(c, stdin); } return 0; } aaaa Point out the error in the following program. #include<stdio.h> int main() { fprintf("IndiaBIX"); printf("%.ef", 2.0); return 0; } Point out the error in the following program. #include<stdio.h> int main() { char str[] = "IndiaBIX"; printf("%.#s %2s", str, str); return 0; } Error: in Array declaration Point out the error in the following program. #include<stdio.h> int main() { fprintf("IndiaBIX"); printf("%.ef", 2.0); return 0; }
57
58
Error: unknown value in printf() statement
59
60
Error: unknown value in printf() statement
Point out the error in the following program. #include<stdio.h> int main() { fprintf("IndiaBIX"); printf("%.ef", 2.0); return 0; } How many times the while loop will get executed if a short int is 2 byte wide? #include<stdio.h> int main() { int j=1; while(j <= 255) { printf("%c %d\n", j, j); j++; } return 0; } Infinite times 63 Which of the following is not logical operator? &
61
Error: unknown value in printf() statement.
62
64
In mathematics and computer programming, which is the Addition, Subtraction, correct order of mathematical operators ? Multiplication, Division
65
Which of the following cannot be checked in a switch-case statement? Character
66
What will be the output of the program? #include<stdio.h> int main() { int i=0; for(; i<=5; i++); printf("%d", i); return 0; } 0, 1, 2, 3, 4, 5 What will be the output of the program? #include<stdio.h> int main() { char str[]="C-program"; int a = 5; printf(a >10?"Ps\n":"%s\n", str); return 0; } C-program What will be the output of the program? #include<stdio.h> int main() { int a = 500, b = 100, c; if(!a >= 400) b = 300; c = 200; printf("b = %d c = %d\n", b, c); return 0; } b = 300 c = 200 What will be the output of the program? #include<stdio.h> int main() { unsigned int i = 65535; /* Assume 2 byte integer*/ while(i++ != 0) printf("%d",++i); printf("\n"); return 0;
67
68
69
Infinite loop
70
What will be the output of the program? #include<stdio.h> int main() { int x = 3; float y = 3.0; if(x == y) printf("x and y are equal"); else printf("x and y are not equal"); return 0; } x and y are equal What will be the output of the program, if a short int is 2 bytes wide? #include<stdio.h> int main() { short int i = 0; for(i<=5 && i>=-1; ++i; i>0) printf("%u,", i); return 0; What will be the output of the program? #include<stdio.h> int main() { char ch; if(ch = printf("")) printf("It matters\n"); else printf("It doesn't matters\n"); return 0; } It matters What will be the output of the program? #include<stdio.h> int main() { unsigned int i = 65536; /* Assume 2 byte integer*/ while(i != 0) printf("%d",++i); printf("\n"); return 0;
71
1 ... 65535
72
73
Infinite loop
74
What will be the output of the program? #include<stdio.h> int main() { float a = 0.7; if(0.7 > a) printf("Hi\n"); else printf("Hello\n"); return 0; } Hi What will be the output of the program? #include<stdio.h> int main() { int a=0, b=1, c=3; *((a) ? &b : &a) = a ? b : c; printf("%d, %d, %d\n", a, b, c); return 0; } 0, 1, 3 What will be the output of the program? #include<stdio.h> int main() { int k, num = 30; k = (num < 10) ? 100 : 200; printf("%d\n", num); return 0; } 200 What will be the output of the program? #include<stdio.h> int main() { int a = 300, b, c; if(a >= 400) b = 300; c = 200; printf("%d, %d, %d\n", a, b, c); return 0; } 300, 300, 200
75
76
77
78
What will be the output of the program? #include<stdio.h> int main() { int x=1, y=1; for(; y; printf("%d %d\n", x, y)) { y = x++ <= 5; } printf("\n"); return 0; }
21 31 41 51 61 70
79
What will be the output of the program? #include<stdio.h> int main() { int x, y, z; x=y=z=1; z = ++x || ++y && ++z; printf("x=%d, y=%d, z=%d\n", x, y, z); return 0; } x=2, y=1, z=1 Point out the error, if any in the program. #include<stdio.h> int main() { int a = 10; switch(a) { } printf("This is c program."); return 0; }
80
Error: No case statement specified
81
Point out the error, if any in the while loop. #include<stdio.h> int main() { int i=1; while() { printf("%d\n", i++); if(i>10) break; } return 0; } Point out the error in the program
There should be a condition in the while loop
82
83
f(int a, int b) { int a; a = 20; return a; } Which of the following statements are correct about the below program? #include<stdio.h> int main() { int i = 10, j = 20; if(i = 5) && if(j = 10) printf("Have a nice day"); return 0; }
Missing parenthesis in return statement
Output: Have a nice day
84
Which of the following statements are correct about the program? #include<stdio.h> int main() { int x = 30, y = 40; if(x == y) printf("x is equal to y\n"); else if(x > y) printf("x is greater than y\n"); else if(x < y) printf("x is less than y\n") return 0; } Error: Statement missing Which of the following statements are correct about the below C-program? #include<stdio.h> int main() { int x = 10, y = 100%90, i; for(i=1; i<10; i++) if(x != y); printf("x = %d y = %d\n", x, y); return 0; } Which of the following sentences are correct about a switch loop in a C program? 1: switch is useful when we wish to check the value of variable against a particular set of values. 2: switch is useful when we wish to check whether a value falls in different ranges. 3: Compiler implements a jump table for cases used in switch. 4: It is not necessary to use a break in every switch statement. 1,2
85
Error: Declaration terminated incorrectly
86
87
What will happen if in a C program you assign a value to an The element will be set to array element whose subscript exceeds the size of array? 0.
88
What does the following declaration mean? int (*ptr)[10];
ptr is array of pointers to 10 integers
89
In C, if you pass an array as an argument to a function, what actually gets passed?
Value of elements in array
90
Which of the following statements mentioning the name of the array begins DOES NOT yield the base address?1: When array name is used with the sizeof operator. 2: When array name is operand of the & operator. 3: When array name is passed to scanf() function. 4: When array name is passed to printf() function. A
91
Which of the following statements are correct about an array? 1: The array int num[26]; can store 26 elements. 2: The expression num[1] designates the very first element in the array. 3: It is necessary to initialize the array at the time of declaration. 4: The declaration num[SIZE] is allowed if SIZE is a macro. 1 What will the SWAP macro in the following program be expanded to on preprocessing? will the code compile? #include<stdio.h> #define SWAP(a, b, c)(c t; t=a, a=b, b=t) int main() { int x=10, y=20; SWAP(x, y, int); printf("%d %d\n", x, y); return 0; } It compiles
92
93 Compiles and print nothing During editing
94
The maximum combined length of the command-line arguments including the spaces between adjacent arguments is
128 characters c' means argument control 'v' means argument vector
95 What do the 'c' and 'v' in argv stands for? 96
Which of the following function is used to find the first occurrence of a given string in another string?
strchr()
97
Which of the following function is more appropriate for reading in a multi-word string? Which of the following is/are storage class
printf(); Automatic To stop indirection in a recursive data structure to terminate a case in the switch statement
98 99
NULL Pointer can be used as 100 The use of break Statement
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
SOLUTION
ANSWER
20
30
During linking
During execution
During preprocessing
strnset()
strset()
strcset()
0 YES
echo "\\n";
printf('\n');
printf("\\n");
laststr()
strrchr()
strstr()
strrchr()
strstr()
strnset()
scanf();
gets();
puts();
World
Hello World
WorldHello
65
12
Good
Morning
bca
Infinite loop
cba
India BIX
India
BIX
Suresh, Siva, Sona, Ritu, Baiju
Suresh, Siva, Baiju, Suresh, Siva, Ritu, Sona, Sona, Ritu Baiju
C++
NULL
Compilation error
ptr is pointer to ptr is array of pointer such function which ptr is pointer to array of to function return type is array function
k, k
n, k
m, f
short int, double, long int
float, double, long double
double, long int, float
#include<math.h>
#include<stdlib.h>
#include<dos.h>
101.011
101011 None of above
use 3.14f
use f(3.14)
use (f)(3.14)
C++
Compiler error
Non of above
Error: Prototype sqrt() 6 not found
4, 8, 8
4, 8, 10
4, 8, 12
1.500000, 1.500000 Representation of void pointer
1.550000, 2.000000 1.000000, 2.000000
Error
None of above
char *p = (char) malloc(100);
char *p = char *p = (char (char*)malloc(100); *)(malloc*)(100);
stddef.h
stdio.h and stddef.h math.h
&
->
*(*(*(*(a+i)+j)+k)+l) A variable that stores address of an instruction
(((a+i)+j)+k+l) A variable that stores address of other variable
((a+i)+j+k+l)
All of the above
&
&&
||
ack
ite
let
27
x=31, y=500, z=500
x=31, y=498, z=498 x=31, y=504, z=504
No output
%s
20, 4, 4
16, 2, 2
20, 2, 2
Error: suspicious pointer conversion
No error
None of above
float *fun(float**);
float fun(float***); float ****fun(float***);
k is a pointer to a pointer to a pointer k is a pointer to a to a pointer to a char char pointer
k is a pointer to a pointer to a char
Output: 1
Output: 3
Error: Invalid indirection
free(var-name);
delete(var-name); dalloc(var-name);
All of them let you define new data types
All of them let you All of them let you define new pointers define new structures
-1, 2, 6, 3, 4, 5
-1, 0, 6, 2, 3, 4
-1, 0, 6, 7, 8, 9
Error Reposition the file pointer stream to end of file.
0, 1, 6, 3, 4, 5
0, 0, 6, 7, 8, 9
Reposition the file Reposition the file pointer to begining pointer to begining of of that line. file.
stdlib.h
stdio.h
dos.h
stdlib.h
stdio.h
dos.h
strchar()
strrchar()
strrchr()
standard error standard error types streams
standard error definitions
flushes only specified flushes stream input/output buffer flushes file buffer. returns a random returns a random number generator number generator in with a random return a random number the specified range. value based on time with a given seed value
How r u 8 2
How r u 1 1
Error: cannot assign printf to variable
2 Garbage value Convert floatingpoint number to a string
Error: cannot assign scanf to variable
Covert multi Convert 2D array in Dimensional array to 1D to 1D array. array
aaaaa
Garbage value.
Error in ungetc statement
Error: in fprintf() statement
No error and prints "IndiaBIX" No error and prints "2.0"
Error: printf statement
Error: unspecified character in printf
No error
Error: in fprintf() statement
No error and prints "IndiaBIX" No error and prints "2.0"
Error: in fprintf() statement
No error and prints "IndiaBIX" No error and prints "2.0"
255 times
256 times
254 times
&&
||
Division, Multiplication, Multiplication, Addition, Division, Addition, Subtraction Subtraction
Addition, Division, Modulus, Subtraction
Integer
Float
enum
1, 2, 3, 54 6 D
Ps
Error
None of above
b = 100 c = garbage
b = 300 c = garbage b = 100 c = 200
0 1 2 ... 65535
0 1 2 ... 32767 32766 -32765 -1 0
No output
x and y are not equal Unpredictable
No output
Expression syntax error
No output
0, 1, 2, 3, 4, 5
It doesn't matters
matters
No output
0 1 2 ... 65535
0 1 2 ... 32767 32766 -32765 -1 0
No output
Hello
Hi Hello
None of above
1, 2, 3
3, 1, 3
1, 3, 1
30
100
500
Garbage, 300, 200
300, Garbage, 200
300, 300, Garbage
21 31 41 51 61
21 31 41 51
22 33 44 55 A
x=2, y=2, z=1
x=2, y=2, z=2
x=1, y=2, z=1
Error: No default specified
No Error
Error: infinite loop occurs
There should be at least a semicolon in the while
The while loop should be replaced with for loop. No error
The function should be defined as int f(int a, int b) Redeclaration of a
None of above
No output
Error: Expression syntax
Error: Undeclared identifier if
Error: Expression syntax
Error: Lvalue required
Error: Rvalue required
Error: Syntax error
Error: Lvalue required
None of above
1,3,4
2,4 The program may crash if some important data gets The array size would overwritten. appropriately grow.
The compiler would report an error.
ptr is a pointer to an ptr is an array of 10 array of 10 integers integers ptr is an pointer to array
First element of the array
Base address of the Address of the last array element of array
A, B
B, D
1,4
2,3
2,4
Compiles with an warning
Not compile
Compiles and print nothing
During linking
During execution
During preprocessing
256 characters c' means argument count 'v' means argument vertex
67 characters
It may vary from one operating system to another
c' means argument c' means argument count 'v' means configuration 'v' means argument vector argument visibility
strrchr()
strstr()
strnset()
scanf(); Satatic
gets(); Allocated
puts(); All the above
C D
As an error value
As an sentinel value All the above
to force immediate termination of a loop Both A & B
Only A
NO.
QUESTION
1 Which of the following type of class allows only one object of it to be created? Virtual class
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
94
95
96
97
98
99
100
Abstract class
Singleton class
Friend class
SOLUTION
ANSWER