Interviews C-Language Programs with Outputs and Explanations PDF

Update Google Drive App

Source: Campus Placement Tricks - Useful and helpful for Recruitment Tests and/ Exams.

www.matterhere.com - Nareddula Rajeev Reddy (NRR)

Question 1
view source print? #include <stdio.h> int main() {
printf("%d", main); getchar(); return 0; }
Output: Address of function main. Explanation: Name of the function is actually a pointer variable to the function and prints the address of the function. Symbol table is implemented like this.
struct {
char *name; int (*funcptr)(); } symtab[] = {
"func", func, "anotherfunc", anotherfunc, };

Question 2
view source print? #include <stdio.h> int main() {
printf("\new_c_question\by"); printf("\rgeeksforgeeks");
getchar(); return 0; }
Output: geeksforgeeksl Explanation: First printf prints 3ew_c_questioy ́. Second printf has \r in it so it goes back to start of the line and starts printing characters.
Now try to print following without using any of the escape characters.
new c questions by geeksforgeeks

Question 3
view source print? # include<stdio.h> # include<stdlib.h>
void fun(int *a) {
a = (int*)malloc(sizeof(int)); }
int main() {
int *p; fun(p); *p = 6; printf("%d\n",*p);
getchar(); return(0); }
Output: 6 Explanation: It does not work. Try replacing 3int *p; ́ with 3int *p = NULL; ́ and it will try to dereference a null pointer.
This is because fun() makes a copy of the pointer, so when malloc() is called, it is setting the copied pointer to the memory location, not p. p is pointing to random memory before and after the call to fun(), and when you dereference it, it will crash.
If you want to add memory to a pointer from a function, you need to pass the address of the pointer (ie. double pointer).
Thanks to John Doe for providing the correct solution.

Question 4
view source
print? #include <stdio.h> int main() {
int i; i = 1, 2, 3; printf("i = %d\n", i);
getchar(); return 0; }
Output: 1 The above program prints 1. Associativity of comma operator is from left to right, but = operator has higher precedence than comma operator. Therefore the statement i = 1, 2, 3 is treated as (i = 1), 2, 3 by the compiler.
Now it should be easy to tell output of below program.
view source print? #include <stdio.h> int main() {
int i; i = (1, 2, 3); printf("i = %d\n", i);
getchar(); return 0; }


Question 5
view source print? #include <stdio.h> int main() {
int first = 50, second = 60, third; third = first /* Will this comment work? */ + second; printf("%d /* And this? */ \n", third);
getchar(); return 0; }
Output: 110 /* And this? */ Explanation: Compiler removes everything between 3/* ́ and 3*/ ́ if they are not present inside double quotes (3 ́).

Following questions have been asked in GATE CS exam.

1. What does the following program print?
view source
print?
#include<stdio.h>
void f(int *p, int *q)
{
p = q;
*p = 2;
}
int i = 0, j = 1;
int main()
{
f(&i, &j);
printf("%d %d \n", i, j);
getchar();
return 0;
}
(A) 2 2 
(B) 2 1
(C) 0 1 
(D) 0 2
Answer (D) See below f() with comments for explanation.
view source
print?
/* p points to i and q points to j */
void f(int *p, int *q)
{
p = q; /* p also points to j now */
*p = 2; /* Value of j is changed to 2 now */
}

2. What is the value printed by the following C program?
view source
print?
#include<stdio.h>
int f(int *a, int n)
{
if(n <= 0) return 0;
else if(*a % 2 == 0) return *a + f(a+1, n-1);
else return *a - f(a+1, n-1);
}
int main()
{
int a[] = {12, 7, 13, 4, 11, 6};
printf("%d", f(a, 6));
getchar();
return 0;
}
(A) -9 
(B) 5 
(C) 15 
(D) 19
Answer (C) f() is a recursive function which adds f(a+1, n-1) to *a if *a is even. If *a is odd then f() subtracts f(a+1, n-1) from *a. See below recursion tree for execution of f(a, 6). .
f(add(12), 6) /*Since 12 is first element. a contains address of 12 */
| | 12 + f(add(7), 5) /* Since 7 is the next element, a+1 contains address of 7 */
| | 7 - f(add(13), 4)

| | 13 - f(add(4), 3)
| | 4 + f(add(11), 2)
| | 11 - f(add(6), 1) 
| | 6 + 0
So, the final returned value is 12 + (7 ± (13 ± (4 + (11 ± (6 + 0))))) = 15
Please write comments if you find any of the answers/explanations incorrect, or you want to share more information about the topics discussed above.

Question 1
view source
print?
#include<stdio.h>
#define R 10
#define C 20
int main()
{
int (*p)[R][C];
printf("%d", sizeof(*p));
getchar();
return 0;
}
Output: 10*20*sizeof(int) which is 3800 for compilers with integer size as 4 bytes. The pointer p is de-referenced, hence it yields type of the object. In the present case, it is an array of array of integers. So, it prints R*C*sizeof(int). Thanks to Venki for suggesting this solution.

Question 2
view source
print?
#include<stdio.h>
#define f(g,g2) g##g2
int main()
{
int var12 = 100;
printf("%d", f(var,12));
getchar();
return 0;
}
Output: 100 The operator ## is called 3Token-Pasting ́ or 3Merge ́ Operator. It merges two tokens into one token. So, after preprocessing, the main function becomes as follows, and prints 100.
view source
print?
int main()
{
int var12 = 100;
printf("%d", var12);
getchar();
return 0;
}

Question 3
view source
print?
#include<stdio.h>
int main()
{
unsigned int x = -1;
int y = ~0;
if(x == y)
printf("same");
else
printf("not same");
printf("\n x is %u, y is %u", x, y);
getchar();
return 0;
}
Output: 3 same x is MAXUINT, y is MAXUINT ́ Where MAXUINT is the maximum possible value for an unsigned integer. -1 and ~0 essentially have same bit pattern, hence x and y must be same. In the comparison, y is promoted to unsigned and compared against x. The result is 3same ́. However, when interpreted as signed and unsigned their numerical values will differ. x is MAXUNIT and y is -1. Since we have %Predict the output of below C programs.

Question 1
view source
print?
#include <stdio.h>
char* fun()
{
return "awake";
}
int main()
{
printf("%s",fun()+ printf("I see you"));
getchar();
return 0;
}
Output: Some string starting with 3I see you ́ Explanation: (Thanks to Venki for suggesting this solution) The function fun() returns pointer to char. Apart from printing string 3I see you ́, printf() function returns number of characters it printed(i.e. 9). The expression [fun()+ printf("I see you")] can be boiled down to ["awake" + 9] which is nothing but base address of string literal 3awake ́ displaced by 9 characters. Hence, the expression ["awake" + 9] returns junk data when printed via %s specifier till it finds μ\0 .

Question 2
view source
print?
#include <stdio.h>
int main()
{
unsigned i ;
for( i = 0 ; i < 4 ; ++i )
{
fprintf( stdout , "i = %d\n" , ("11213141") ) ;
}
getchar();
return 0 ;
}
Output: Prints different output on different machines. Explanation: (Thanks to Venki for suggesting this solution) The format specifier is %d, converts the base address of string 311213141 as an integer. The base address of string depends on memory allocation by the compiler. The for loop prints same address four times. Try to use C++ streams, you will see power of type system.
u for y also, the output will be MAXUNIT and MAXUNIT.

Output of C Programs | Set 15
Predict the output of below C programs.
Question 1
view source
print?
#include<stdio.h>
int main(void)
{
int a = 1;
int b = 0;
b = ++a + ++a;
printf("%d %d",a,b);
getchar();
return 0;
}
Output: Undefined Behavior See http://en.wikipedia.org/wiki/C_syntax#Undefined_behavior )

Question 2
view source
print?
#include<stdio.h>
int main()
{
int a[] = {1, 2, 3, 4, 5, 6};
int *ptr = (int*)(&a+1);
printf("%d ", *(ptr-1) );
getchar();
return 0;
}
Output: 6 &a is address of the whole array a[]. If we add 1 to &a, we get 3base address of a[] + sizeof(a) ́. And this value is typecasted to int *. So ptr ± 1 points to last element of a[]
Please write comments if you find any of the answers/explanations incorrect, or you want to share more information about the topics discussed above.
Predict the output of below C programs.

Question 1
view source
print?
#include<stdio.h>
int main()
{
int a;
char *x;
x = (char *) &a;
a = 512;
x[0] = 1;
x[1] = 2;
printf("%d\n",a);
getchar();
return 0;
}
Answer: The output is dependent on endianness of a machine. Output is 513 in a little endian machine and 258 in a big endian machine.
Let integers are stored using 16 bits. In a little endian machine, when we do x[0] = 1 and x[1] = 2, the number a is changed to 00000001 00000010 which is representation of 513 in a little endian machine. The output would be same for 32 bit numbers also.
In a big endian machine, when we do x[0] = 1 and x[1] = 2, the number is changed to 00000001 00000010 which is representation of 258 in a big endian machine.

Question 2
view source
print?
int main()
{
int f = 0, g = 1;
int i;
for(i = 0; i < 15; i++)
{
printf("%d \n", f);
f = f + g;
g = f - g;
}
getchar();
return 0;
}
Answer: The function prints first 15 Fibonacci Numbers.
Question 3 Explain functionality of following function.
view source
print?
int func(int i)
{
if(i%2) return (i++);
else return func(func(i-1));
}
Answer: If n is odd then returns n, else returns (n-1). So if n is 12 then we get and if n is 11 then we get 11.
Please write comments if you find any of the answers/explanations incorrect, or you want to share more information about the topics discussed above.

Question 1 Predict the output of below program.
view source
print?
int main()
{
char arr[] = "geeksforgeeks";
printf("%d", sizeof(arr));
getchar();
return 0;
}
Output: 14 The string 3geeksforgeeks ́ has 13 characters, but the size is 14 because compiler includes a single μ\0 (string terminator) when char array size is not explicitly mentioned.

Question 2 In below program, what would you put in place of 3? ́ to print 3geeks ́. Obviously, something other than 3geeks ́.
view source
print?
int main()
{
char arr[] = "geeksforgeeks";
printf("%s", ?);
getchar();
return 0;
}
Answer: (arr+8) The printf statement prints everything starting from arr+8 until it finds μ\0¶
Question 3 Predict the output of below program.
view source
print?
int main()
{
int x, y = 5, z = 5;
x = y==z;
printf("%d", x);
getchar();
return 0;
}
The crux of the question lies in the statement x = y==z. The operator == is executed before = because precedence of comparison operators (<=, >= and ==) is higher than assignment operator =. The result of a comparison operator is either 0 or 1 based on the comparison result. Since y is equal to z, value of the expression y == z becomes 1 and the value is assigned to x via the assignment operator.

Question 4 Predict the output of below program.
view source
print?
int main()
{
printf(" \"GEEKS %% FOR %% GEEKS\"");
getchar();
return 0;
}
Output: 3GEEKS % FOR % GEEKS ́
Predict the output of below programs.

Question 1
view source
print?
int fun(char *str1)
{
char *str2 = str1;
while(*++str1);
return (str1-str2);
}
int main()
{
char *str = "geeksforgeeks";
printf("%d", fun(str));
getchar();
return 0;
}
Output: 13 Inside fun(), pointer str2 is initialized as str1 and str1 is moved till μ\0¶ is reached (note ; after while loop). So str1 will be incremented by 13 (assuming that char takes 1 byte).

Question 2
view source
print?
void fun(int *p)
{
static int q = 10;
p = &q;
}
int main()
{
int r = 20;
int *p = &r;
fun(p);
printf("%d", *p);
getchar();
return 0;
}
Output: 20 Inside fun(), q is a copy of the pointer p. So if we change q to point something else then p remains unaffected.

Question 3
view source
print?
void fun(int **p)
{
static int q = 10;
*p = &q;
}
int main()
{
int r = 20;
int *p = &r;
fun(&p);
printf("%d", *p);
getchar();
return 0;
}
Output 10
Note that we are passing address of p to fun(). p in fun() is actually a pointer to p in main() and we are changing value at p in fun(). So p of main is changed to point q of fun(). To understand it better, let us rename p in fun() to p_ref or ptr_to_p
view source
print?
void fun(int **ptr_to_p)
{
static int q = 10;
*ptr_to_p = &q; /*Now p of main is pointing to q*/
}
Also, note that the program won¶t cause any problem because q is a static variable. Static variables exist in memory even after functions return. For an auto variable, we might have seen some weird output because auto variable may not exist in memory after functions return.

Output of C Programs | Set 10
Predict the output of the below programs.
Difficulty Level: Rookie
Question 1
view source
print?
#include<stdio.h>
int main()
{
typedef int i;
i a = 0;
printf("%d", a);
getchar();
return 0;
}
Output: 0 There is no problem with the program. It simply creates a user defined type i and creates a variable a of type i.

Question 2
view source
print?
#include<stdio.h>
int main()
{
typedef int *i;
int j = 10;
i *a = &j;
printf("%d", **a);
getchar();
return 0;
}
Output: Compiler Error -> Initialization with incompatible pointer type. The line typedef int *i makes i as type int *. So, the declaration of a means a is pointer to a pointer. The Error message may be different on different compilers.

Question 3
view source
print?
#include<stdio.h>
int main()
{
typedef static int *i;
int j;
i a = &j;
printf("%d", *a);
getchar();
return 0;
}
Output: Compiler Error -> Multiple Storage classes for a. In C, typedef is considered as a storage class. The Error message may be different on different compilers.
Predict the output of the below programs.

Question 1
view source
print?
int main()
{
int c=5;
printf("%d\n%d\n%d", c, c <<= 2, c >>= 2);
getchar();
}
Output: Compiler dependent Evaluation order of parameters is not defined by C standard and is dependent on compiler implementation. It is never safe to depend on the order of parameter evaluation. For example, a function call like above may very well behave differently from one compiler to another.
References: http://gcc.gnu.org/onlinedocs/gcc/Non_002dbugs.html

Question 2
view source
print?
int main()
{
char arr[] = {1, 2, 3};
char *p = arr;
if(&p == &arr)
printf("Same");
else
printf("Not same");
getchar();
}
Output: Not Same &arr is an alias for &arr[0] and returns the address of the first element in array, but &p returns the address of pointer p. Now try below program
view source
print?
int main()
{
char arr[] = {1, 2, 3};
char *p = arr;
if(p == &arr)
printf("Same");
else
printf("Not same");
getchar();
}

Question 3
view source
print?
int main()
{
char arr[] = {1, 2, 3};
char *p = arr;
printf(" %d ", sizeof(p));
printf(" %d ", sizeof(arr));
getchar();
}
Output 4 3 sizeof(arr) returns the amount of memory used by all elements in array and sizeof(p) returns the amount of memory used by the pointer variable itself.

Question 4
view source
print?
int x = 0;
int f()
{
return x;
}
int g()
{
int x = 1;
return f();
}
int main()
{
printf("%d", g());
printf("\n");
getchar();
}
Output: 1 In C, variables are always statically (or lexically) scoped. Binding of x inside f() to global
variable x is defined at compile time and not dependent on who is calling it. Hence, output for the above program will be 0.
On a side note, Perl supports both dynamic ans static scoping. Perl¶s keyword 3my ́ defines a statically scoped local variable, while the keyword 3local ́ defines dynamically scoped local variable. So in Perl, similar (see below) program will print 1.
view source
print?
$x = 0;
sub f
{
return $x;
}
sub g
{
local $x = 1; return f();
}
print g()."\n";
Predict the output of below C programs. Question 1:
view source
print?
#include<stdio.h>
int main()
{
int x = 5, p = 10;
printf("%*d", x, p);
getchar();
return 0;
}
Output: 10
Explanation: Please see standard printf function definition
int printf ( const char * format, ... );
format: String that contains the text to be written to stdout. It can optionally contain embedded format tags that are substituted by the values specified in subsequent argument(s) and formatted as requested. The number of arguments following the format parameters should at least be as much as the number of format tags. The format tags follow this prototype:
%[flags][width][.precision][length]specifier
You can see details of all above parts here http://www.cplusplus.com/reference/clibrary/cstdio/printf/.
The main thing to note is below the line about precision * (star): The precision is not specified in the format string, but as an additional integer value argument preceding the argument that has to be formatted.
So, in the above example 5 is precision and 10 is the actual value to be printed. (Thanks to Ajay Mishra for providing the solution)

Question 2
view source
print?
int main()
{
char arr[] = "geeksforgeeks";
char *ptr = arr;
while(*ptr != '\0')
++*ptr++;
printf("%s %s", arr, ptr);
getchar();
return 0;
}
Output: hffltgpshfflt
Explanation: The crust of this question lies in expression ++*ptr++.
If one knows the precedence and associativity of the operators then there is nothing much left. Below is the precedence of operators.
Postfixx ++ left-to-right Prefix ++ right-to-left Dereference * right-to-left
Therefore the expression ++*ptr++ has following effect Value of *ptr is incremented Value of ptr is incremented

Question 3
view source
print?
int main()
{
signed char i=0;
for(; i >= 0; i++);
printf("%d\n", i);
getchar();
return 0;
}
Output: -128
Explanation: Here, the first thing to be noticed is the semi-colon in the end of for loop. So basically, there¶s no body for the for loop. And printf will print the value of i when control comes out of the for loop. Also, notice that the first statement i.e. initializer in the for loop is not present. But i has been initialized at the declaration time. Since i is a signed character, it can take value from -128 to 127. So in the for loop, i will keep incrementing and the condition is met till roll over happens. At the roll over, i will become -128 after 127, in that case condition is not met and control comes out of the for loop.

Question 4
view source
print?
#include <stdio.h>
void fun(const char **p) { }
int main(int argc, char **argv)
{
fun(argv);
getchar();
return 0;
}
Output: Compiler error.
Explanation: Parameter passed to fun() and parameter expected in definition are of incompatible types. fun() expects const char** while passed parameter is of type char **.
Now try following program, it will work.
void fun(const char **p) { } int main(int argc, char **argv) {
const char **temp; fun(temp); getchar(); return 0; }
Predict the output of below programs

Question 1
view source
print?
void main()
{
while(1){
if(printf("%d",printf("%d")))
break;
else
continue;
}
}
Output: Can¶t be predicted
Explanation: The condition in while loop is 1 so at first shot it looks infinite loop. Then there are break and continue in the body of the while loop, so it may not be infinite loop. The break statement will be executed if the condition under if is met, otherwise continue will be executed. Since there¶s no other statements after continue in the while loop, continue doesn¶t serve any purpose. In fact it is extraneous. So let us see the if condition. If we look carefully, we will notice that the condition of the if will be met always, so break will be executed at the first iteration itself and we will come out of while loop. The reason why the condition of if will be met is printf function. Function printf always returns the no. of bytes it has output. For example, the return value of printf(3geeks ́) will be 5 because printf will output 5 characters here. In our case, the inner printf will be executed first but this printf doesn¶t have argument for format specifier i.e. %d. It means this printf will print any arbitrary value. But notice that even for any arbirary value, the no. of bytes output by inner printf would be non-zero. And those no. of bytes will work as argument to outer printf. The outer printf will print that many no. of bytes and return non-zero value always. So the condition for if is also true always. Therefore, the while loop be executed only once. As a side note, even without outer printf also, the condition for if is always true.

Question 2
view source
print?
main()
{
unsigned int i=10;
while(i-->=0)
printf("%u ",i);
}
Output: 9 8 7 6 5 4 3 2 1 0 4294967295 4294967294 «« (on a machine where int is 4 bytes long)
9 8 7 6 5 4 3 2 1 0 65535 65534 «. (on a machine where int is 2 bytes long)
Explanation: Let us examine the condition of while loop. It is obvious that as far as the condition of while loop is met, printf will be executed. There are two operators in the condition of while loop: post- decrement operator and comparison operator. From operator precedence, we know that unary
operator post-decrement has higher priority than comparison operator. But due to post-decrement property, the value of i will be decremented only after it had been used for comparison. So at the first iteration, the condition is true because 10>=0 and then i is decremented. Therefore 9 will be printed. Similarly the loop continues and the value of i keeps on decrementing. Let us see what what happen when condition of while loop becomes 0 >= 0. At this time, condition is met and i is decremented. Since i is unsigned integer, the roll-over happens and i takes the value of the highest +ve value an unsigned int can take. So i is never negative. Therefore, it becomes infinite while loop.
As a side note, if i was signed int, the while loop would have been terminated after printing the highest negative value.

Question 3
view source
print?
main()
{
int x,y=2,z,a;
if(x=y%2) z=2;
a=2;
printf("%d %d ",z,x);
}
Output: 0
Explanation: This question has some stuff for operator precedence. If the condition of if is met, then z will be initialized to 2 otherwise z will contain garbage value. But the condition of if has two operators: assignment operator and modulus operator. The precedence of modulus is higher than assignment. So y%2 is zero and it¶ll be assigned to x. So the value of x becomes zero which is also the effective condition for if. And therefore, condition of if is false.

Question 4
view source
print?
main()
{
int a[10];
printf("%d",*a+1-*a+3);
}
Output: 4
Explanation: From operator precedence, de-reference operator has higher priority than addition/subtraction operator. So de-reference will be applied first. Here, a is an array which is not initialized. If we use a, then it will point to the first element of the array. Therefore *a will be the first element of the array. Suppose first element of array is x, then the argument inside printf becomes as follows. It¶s effective value is 4.
x + 1 ± x + 3 = 4

Question 5
view source
print?
#define prod(a,b) a*b
main()
{
int x=3,y=4;
printf("%d",prod(x+2,y-1));
}
Output: 10
Explanation: This program deals with macros, their side effects and operator precedence. Here prod is a macro which multiplies its two arguments a and b. Let us take a closer look.
prod(a, b) = a*b prod(x+2, y-1) = x+2*y-1 = 3+2*4-1 = 3+8-1=10
If the programmer really wanted to multiply x+2 and y-1, he should have put parenthesis around a and b as follows.
prod(a,b) = (a)*(b)
This type of mistake in macro definition is called ± macro side-effects.
Predict the output of below programs

Question 1
view source
print?
#include1⁄2stdio.h3⁄4
int main()
{
struct site
{
char name[] = "GeeksforGeeks";
int no_of_pages = 200;
};
struct site *ptr;
printf("%d",ptr->x);
printf("%s",ptr->name);
getchar();
return 0;
}
Output: Compiler error
Explanation: Note the difference between structure/union declaration and variable declaration. When you declare a structure, you actually declare a new data type suitable for your purpose. So you cannot initialize values as it is not a variable declaration but a data type declaration.
Reference: http://www.lix.polytechnique.fr/~liberti/public/computing/prog/c/C/SYNTAX/struct.html

Question 2
view source
print?
int main()
{
char a[2][3][3] = {'g','e','e','k','s','f','o',
'r','g','e','e','k','s'};
printf("%s ", **a);
getchar();
return 0;
}
Output: geeksforgeeks
Explanation: We have created a 3D array that should have 2*3*3 (= 18) elements, but we are initializing only 13 of them. In C when we initialize less no of elements in an array all uninitialized elements become μ\0 in case of char and 0 in case of integers.

Question 3
view source
print?
int main()
{
char str[]= "geeks\nforgeeks";
char *ptr1, *ptr2;
ptr1 = &str[3];
ptr2 = str + 5;
printf("%c", ++*str - --*ptr1 + *ptr2 + 2);
printf("%s", str);
getchar();
return 0;
}
Output: heejs forgeeks
Explanation: Initially ptr1 points to μk¶ and ptr2 points to μ\n¶ in 3geeks\nforgeeks ́. In print statement value at str is incremented by 1 and value at ptr1 is decremented by 1. So string becomes 3heejs\nforgeeks ́ .
First print statement becomes printf(3%c ́, μh¶ ± μj¶ + μn¶ + 2)
μh¶ ± μj¶ + μ\n¶ + 2 = -2 + μ\n¶ + 2 = μ\n¶
First print statements newline character. and next print statement prints 3heejs\nforgeeks ́.

Question 4
view source
print?
#include <stdio.h>
int fun(int n)
{
int i, j, sum = 0;
for(i = 1;i<=n;i++)
for(j=i;j<=i;j++)
sum=sum+j;
return(sum);
}
int main()
{
printf("%d", fun(15));
getchar();
return 0;
}
Output: 120 Explanation: fun(n) calculates sum of first n integers or we can say it returns n(n+1)/2.

Question 5
view source
print?
#include <stdio.h>
int main()
{
int c = 5, no = 10;
do {
no /= c;
} while(c--);
printf ("%d\n", no);
return 0;
}
Output: Exception ± Divide by zero
Explanation: There is a bug in the above program. It goes inside the do-while loop foe c = 0 also. Be careful when you are using do-while loop like this!!

Question 1
view source
print?
char *getString()
{
char str[] = "Will I be printed?";
return str;
}
int main()
{
printf("%s", getString());
getchar();
}
Output: Some garbage value The above program doesn¶t work because array variables are stored in Stack Section. So, when getString returns values at str are deleted and str becomes dangling pointer.

Question 2
view source
print?
int main()
{
static int i=5;
if(--i){
main();
printf("%d ",i);
}
}
Output: 0 0 0 0 Explanation: Since i is a static variable and is stored in Data Section, all calls to main share same i.

Question 3
view source
print?
int main()
{
static int var = 5;
printf("%d ",var--);
if(var)
main();
}
Output: 5 4 3 2 1 Explanation: Same as previous question. The only difference here is, sequence of calling main and printf is changed, therefore different output.

Question 4
view source
print?
int main()
{
int x;
printf("%d",scanf("%d",&x));
/* Suppose that input value given
for above scanf is 20 */
return 1;
}
Output: 1 scanf returns the no. of inputs it has successfully read.

Question 5
view source
print?
# include <stdio.h>
int main()
{
int i=0;
for(i=0; i<20; i++)
{
switch(i)
{
case 0:
i+=5;
case 1:
i+=2;
case 5:
i+=5;
default:
i+=4;
break;
}
printf("%d ", i);
}
getchar();
return 0;
}
Output: 16 21 Explanation: Initially i = 0. Since case 0 is true i becomes 5, and since there is no break statement till last statement of switch block, i becomes 16. Now in next iteration no case is true, so execution goes to default and i becomes 21.
In C, if one case is true switch block is executed until it finds break statement. If no break statement is present all cases are executed after the true case. If you want to know why switch is implemented like this, well this implementation is useful for situations like below.
switch (c) {
case 'a': case 'e': case 'i' : case 'o': case 'u':
printf(" Vowel character"); break; default :
printf("Not a Vowel character");; break; }
Predict the output of following C programs.

Question 1
view source
print?
#include<stdio.h>
int fun()
{
static int num = 40;
return num--;
}
int main()
{
for(fun(); fun(); fun())
{
printf("%d ", fun());
}
getchar();
return 0;
}
Output: 38 35 32 29 26 23 20 17 14 11 8 5 2
Since num is static in fun(), the old value of num is preserved for subsequent functions calls. Also, since the statement return num± is postfix, it returns the old value of num, and updates the value for next function call.

Question 2
view source
print?
#include<stdio.h>
int main()
{
char *s[] = { "knowledge","is","power"};
char **p;
p = s;
printf("%s ", ++*p);
printf("%s ", *p++);
printf("%s ", ++*p);
getchar();
return 0;
}
Output: nowledge nowledge s
Let us consider the expression ++*p in first printf(). Since precedence of prefix ++ and * is same, associativity comes into picture. *p is evaluated first because both prefix ++ and * are right to left associative. When we increment *p by 1, it starts pointing to second character of 3knowledge ́. Therefore, the first printf statement prints 3nowledge ́.
Let us consider the expression *p++ in second printf() . Since precedence of postfix ++ is higher than *, p++ is evaluated first. And since it¶s a psotfix ++, old value of p is used in this expression. Therefore, second printf statement prints 3nowledge ́.
In third printf statement, the new value of p (updated by second printf) is used, and third printf() prints 3s ́.

Oracle Test:

1.void main() { struct a { char ch[10]; char *str; }; struct a s1={"Hyderabad","Bangalore"}; printf("\n%c%c",s1.ch[0],*s1.str); printf("\n%s%s",s1.ch,s1.str); getch(); }
Ans: HB, HyderabadBangalor

2. main(int argc,int *argv[]) { int i; for(i=1;i printf("\n%s%s",argv[i],(i
return 0; getch(); }
file://
Ans: i work for oracle

3.void main() { int i,j,k; for(i=0;i<3;i++) k=sum(i,i); printf("\n%d",k); getch(); } sum(s,t) { static int m; m+=s+t; return m; } file://
Ans: 6

4.void main() { int i; clrscr(); for(i=1;i<6;++i) switch(i) { case 1: case 2: printf("%d,",i++);break; case 3: continue; case 4: printf("%d,",i); } printf("%d",i); getch(); } file://
Ans: 1,4,6

5.Which of the storage class(es) becomes the global variables for the = entire
Program 
(A) Extern 
(B) Static 
(C) Auto 
(D) Register
ANSWER : A

6.//What is the output of the program void main() { char s[]="oracle is the best"; char t[40]; char *ss,*tt; while(*tt++=*ss++); printf("%s",t); getch(); } // 
A. oracle is the best // 
B. Core dump // 
c. Error Message // 
D. Goes into infinite loop // 
Ans: B. core dump (Garbage value)

7.//What is the output of the program void main() { int j[10]={9,7,5,3,1,2,4,6,9}; int i=1; clrscr(); for(;i<9;i++) printf("%d ",--j[i++]); getch(); } // 
A. 6,2,1,5 // 
B. 6,2,1,5,7 // 
c. Error Message // 
D. core dump // 
Ans: A. 6,2,1,5

8.//What is the output of the program void main()
{ int i,j,k,n=5; clrscr(); for(i=5;i>0;i--) { j=1 k=n&j; k==0?printf("0"):printf("1"); } getch(); } // 
A. 00011 // 
B. 11110 // 
c. 11001 // 
D. 11100 // 
Ans: B. 11110

9.Which of the following storage class(es) became the global variable = for the entire program 
A. Extern 
B. Static=20 
c. Auto 
D. Register 
Ans: A

10.//What is the output of the program, if integer occupies 2 bytes = memory? union { int a; char b; char c[10]; }u1; void main() { int l=sizeof(u1); printf("%d",l); getch(); } // 
A. 13
// 
B. 10 // 

c. 16 // 

D. None of the above // 

Ans: B. 10


11.//What is the output of the program void main() { fork(); printf(" Hello World"); getch(); } // 
A. Hello World // 
B. Hello World Hello World // 
c. Error Message // 
D. None of these // 
Ans: B

12.//What is the output of the program void main() { struct a { int i; char *st1; }; typedef struct a ST; ST *str1; str1=(ST*)malloc(100); str1->i=100; strcpy(str1->st1,"Welcome to Oracle"); printf(" %d%s\n",str1->i,str1->st1); getch(); } // 
A. core dump // 
B. will not compile // 
c. 100,Welcome to Oracle // 
D. None of these // 
Ans: C

13.//What is the output of the program void main()
{ int i,j,k; i=2; j=4; k=i++>j&2; printf("%d\n",k); if(++k && ++i<--j|| i++) { j=++k; } printf(" %d %d %d",i,-j--,k); getch(); } // 
A. 4,-3,2 // 
B. 5,-3,2 // 
c. 4,-2,2 // 
D. 5,-2,2 // 
Ans: D

14.Which of the following is not true incase of Command line arguments 
A.The argc parameter is used to hold the number of arguments in the = command line and is an integer 
B. The argv parameter is a pointer to an array of a character = pointer and each one points to command line arguments 
C. The argv[1] always point to program name 
D. None of above
Ans: C

15. A function without any return type declares return=20 
A. Integer 
B. Float 
C. Void 
D. Syntax Error 
Ans: A

16.//What is the output of the program
#include #include #define sqr(a) a*a void main() { int a=10,b=1,c; c=sqr(10+1); printf("Sqr Root of (10+1)is %d",c ); getch(); } // 
A. 121 // 
B. 21 // 
c. 13 // 
D. Syntax Error // 
Ans: B

17.//What is the output of the program #include #include void main() { int i,j=20; clrscr(); for(i=1;i<3;i++) { printf("%d,",i); continue; printf("%d",j); break; } getch(); } // 
A. 1,20 // 
B. 1,20,1,20 // 
c. 1,2 // 
D. 1,2,20,20 // 
Ans: c

18.//What is the output of the program #include #include void main()
{ int i=1*4/3-27%3^2+100*0.5-(4>3?1:2); clrscr(); printf("%d",i); getch(); } // 
A. 49 // 
B. compile error // 
c. 51 // 
D. 48 // 
Ans: b

19.What is the output of the program #include #include void main() { char *st1[3]= {"Hello","World","Oracle"}; *st1=st1[2]; st1[1]=*st1; free(st1[0]); free(st1[1]); clrscr(); printf("%s %s %s",st1,st1[1],st1[2]); getch(); } // A. Garbage Garbage Oracle // 
B. oracle oracle oracle // 
c. Hello World Oracle // 
D. Core Dump:cannot Print after freeing the memory // 
Ans: D

20.Consider the following structure =20 Struct { int data; struct node *prev; struct node *next; }NODE;
NULL <-- 5 --> 8 --> 10 --> NULL p <-- q <-- r=20
WHAT WILL BE THE VALUE OF r-->prev-->-->next-->data ? 
A. 8 
B. Null 
C. 5 
D. 10 
Ans: 10

21. what will be the output of the fallowing SELECT statement ? SELECT count(*) FROM emp Where exist (select 'X' From dept where dept_name ='Stores' and dept.dept_id=emp.dept_id)
A. select total number of employees belonging to department " stores " 
B. select all employees belonging to department "X" 
C. select all employees belonging to department "stores" 
D. select total number of employees belonging to department "X"

22. Denormalisation is done to=20 
A. Check for Data Integrity 
B. Reduce Data Redundancy 
C. Intoduce Security Check 
D. Increase Query performance .

23. How many columns are retrived from this query: SELECT address1 || ',' ||address2 ||',' ||address2 "Address" FROM = employee;
A. 3 
B. 2 
C. 1 
D. 0

24. What is the is the result of the fallowing Code Piece=20 Insert into table A value(a1): CREATE TABLE B AS SELECT * FROM A; ROLLBAACK ; 
A. Table B gets created with the row inserted in the first statement. 
B. Table B is not created 
C. Table B gets created , but no row gets inserted into Table A 
D. Rollback throws up an exception .

25. The key word used in Oracle for string searching is=20
A. SOUNDEX 
B. DECODE 
C. LIKE 
D. HAVING

26. What does the ROLLBACK statement wil do in the fool segment of = code PROGRAM STARTS HERE ........ SOME DML STAT. ...SAVEPOINT1 SOME DML STAT. ...SAVEPOINT2 SOME DML STAT. ...ROLLBACK 
A. Rollback Dml changes to savepoint 1 
B. Rollback Dml changes to savepoint 2 
C. Rollback Dml changes of the last DML ststs. just before = ROllback stats 
D. Rollback DML changes to the place whre the program starts

27. Which clause u use to exclude the rows before
grouping them? 
A. Group By 
B. Having 
C. Where 
D. Minus

28. Which of the following statements is not true about views? 
A. u can create a index on views 
B. Views donot have permanent data 
C. Views can be based on one or more tables 
D. Views can be dropped without dropping tables

29 How many JION conditions are needed in JOIN query to avoid a = Cartesian Product? 
A. No of tables + 1 
B. No of tables - 1 
C. No of colums + 1 
D. No of colums - 1

30. "An item could be either a component or spare ". How can u = represent this scenerio in a E-R=20 
A. Subtype Relation 
B. Arc Relation 
C. Recursive Relation 
D. Many to Many Relationscription 

MCQ of c programming 1
Q. 1 . TurboC 3.0 is based on 
a . DOS 
b . UNIX 
c . Windows 
d . none 

Q. 2 . Find the output. void main() { int a=4,b=5; printit(a, b); } printit(int b, int a)
{ printf("%d %d", a, b); { int a=0; int b=1; printf("%d %d", a, b); } } 
a . 4 5 0 1 
b . 5 4 0 1 
c . 5 4 5 4 
d . None of these 

Q. 3 . Find the output void main() { int const x=4; int i,a[x]={1,2,3,4}; for(i=0;i<4;i++) x="1.5" y="1.5f" z="1.5" a="b="c="10;" a="10;" a="call(a="call(~a));" i="printf(" a="sizeof(int)/sizeof(float))" a="="1.000000)" a="{2.5};" b="a;" a="5,*p;" p="&a;" i="15;" x="16384,y="1;" ptr="&one_d;" i="1;i<="3;i++)" i="="3)" i="1;i<="3;i++)" i="="3)" p="Hai Bye" i="3;">0) { int i=5; printf("%d",i); i--; } } 
a . 5 4 3 2 1 
b . Error, multiple declaration for i 
c . 3 2 1 
d . Infinite loop 

Q. 28 . The contents of a file will be lost if it is opened in 
a . a mode 
b . a- mode 
c . w+ mode 
d . a+ mode 

Q. 29 . Find the output. void main() { int i=1,j=2,k=3; if(i==1) if(j==2) if(k==3) { printf("ok");
break; } else printf("continue"); printf("bye"); } 
a . ok 
b . okbye 
c . Misplaced break 
d . None of these 

Q. 30 . Find the output void main() { printf("Lakshya\C\Academy"); } 
a . LakshyaCAcademy 
b . LakshyaAcademy 
c . Lakshya 
d . Lakshyacademy

MCQ of c programming 2
Q. 1 . Find out the output void main() { int val=1234; int *ptr=&val; printf("%d %d",++val,(*(int *)ptr)--); } a . 1234 1233 
b . 1235 1234 
c . 1234 1234 
d . None of these 

Q. 2 . Find the correct output void main() { int a=0; for(a;++a;a<=100) printf("%d",a); } 
a . Print 1 to 99 infinite times 
b . Print 1 to 99 
c . Print some garbage values 
d . Infinite loop 

Q. 3 . Find the output void main() { char c[6+4]="kill me"; printf("2%s",c); } 
a . ki 
b . me 
c . kill me 
d . 2kill me 

Q. 4 . Find out the output main() { int i=0;
for(;i++;printf("%d",i)) ; printf("%d",i); } 
a . Infinite loop 
b . 0 1 
c . 1 
d . Stop after printing upto INT_MAX 

Q. 5 . Find out the output. int main(int k) { if(k<5) a="5,b="3,c="2;">b=2?z>3?1:2:3:4); } 
a . 1 
b . 2 
c . 3 
d . 4 

Q. 14 . Find the correct output void main() { int i,j=6; for(;i=j;j-=2) printf("%d",j); } 
a . Error 
b . Garbage values 
c . 642 
d . 6420 

Q. 15 . State the correct statement. 
a . In a while loop the control conditional check is performed n times. 
b . In a do-while loop the control conditional check is performed n+1 times. 
c . Break is a keyword used with if and switch case. 
d . None of these. 

Q. 16 . Find out the output void main() { printf("3","%f",4); } 
a . 34.000000 
b . 4 
c . 3 
d . Error 

Q. 17 . What happens when subscript used for an array exceeds the array size? 
a . Compiler gives an error message 
b . Simply placed excess data outside the array 
c . Simply placed excess data on top of other data or on the program itself. 
d . The program must be compiled. 

Q. 18 . The order of evaluation of operators having same precedence is decided by 
a . Associativity rule 
b . Precedence rule
c . Left-right rule 
d . Right-left rule 

Q. 19 . The set of routines stored in ROM that enable a computer to start the O.S and to communicate with the various devices in the system is known as 
a . device driver 
b . boot parameter 
c . bios 
d . none of these 

Q. 20 . Find the output struct main { int n; int (*p)(); }; void main() { struct main m; int fun(); m.p=fun(); *(m.p); } fun() { printf("Hallo"); } 
a . Hallo 
b . HalloHallo 
c . Error 
d . No output 

Q. 21 . Find the output union uni { int x; int a:8; char b:8; } void main() { union uni u={48}; printf("%d %c", u.a,u.b); } 
a . Invalid initialization 
b . 48 0 
c . 48 48 
d . 0 0 Q. 

22 . An AND gate
a . implements logical addition 
b . is equivalent to a series switching circuit 
c . implements logical subtractions 
d . is equivalent to a parallel switching circuit 

Q. 23 . Find the output void main() { goto cite; { static int a=10; cite: printf("%d",a); } } 
a . 10 
b . Warning, unreachable code 
c . Error 
d . Garbage value 

Q. 24 . Find out the output void main() { int i=3,j=2,k=1; printf("%d / %d"); } 
a . 1 
b . 0 
c . 3/2 
d . 1/2 

Q. 25 . The μcontinue¶ statement is used to 
a . Continue the next iteration of a loop construct. 
b . Exit the block where it exists and continues after. 
c . Exit the outermost block even if it occurs inside the innermost. 
d . Continue the compilation even an error occurs in a program. 

Q. 26 . which of the following declaration is incomplete type? (1) struct tag; (2) struct tag {int a }; (3) typedef struct{int a:}abc 
a . 1 only 
b . 1 and 2 only 
c . 1 and 3 only 
d . 2 and 3 only 

Q. 27 . Find the odd one out 
a . #elif 
b . #line 
c . #else 
d . #ifdef 

Q. 28 . The μcontinue¶ statement is used to
a . Continue the next iteration of a loop construct. 
b . Exit the block where it exists and continues after. 
c . Exit the outermost block even if it occurs inside the innermost. 
d . Continue the compilation even an error occurs in a program. 

Q. 29 . What is the value of EOF which is declared in "stdio.h"? 
a . 0 
b . -1 
c . Any positive value 
d . None of these 

Q. 30 . Which data type behaves like both integer type and character type? 
a . short int 
b . signed int 
c . char 
d . enum 

MCQ of c programming 3
Q. 1 . Find the correct output #include"string.h" void main() { struct node { int data; struct node *next; }; struct node *p,*q; p=(struct node *)malloc(sizeof(struct node)); q=(struct node *)malloc(sizeof(struct node)); p->data=10; q->data=20; p->next=q; q->next=NULL; printf("%d",p->data); p=p->next; printf("%d",p->data); } 
a . 10 20 
b . 10 Garbage value 
c . 20 Garbage value 
d . None of these 

Q. 2 . Find out the output void main() { int x=2,*y=&x;
printf("%d",x*y); } 
a . 4 
b . Garbage 
c . Prints result of multiplication of address of x and x 
d . Error 

Q. 3 . Which of the following function is appropriate to read one character at a time? 
a . fscanf() 
b . fgetc() 
c . read() 
d . fgets() 

Q. 4 . Find out the output main() { const int x=get(); printf("%d",x); } get() { return(20); } 
a . 20 
b . Garbage value 
c . Error 
d . 0 

Q. 5 . Which format specifier is used to find out the offset address of a variable? 
a . %o 
b . %p 
c . %h 
d . %d 

Q. 6 . Find out the output. #define fool !1 - -1 void main() { printf("Hi!"); if (fool) printf("Bye"); } 
a . Lvalue required 
b . Hi! 
c . Bye 
d . Hi!Bye 

Q. 7 . Find out the output void main() {
char str[20]; static int i; for(;;) { i++[str]= 'a'+15; if(i==19) break; i++; } i[str]='\0'; printf("%s",str); } 
a . Error 
b . Garbage value 
c . p 
d . pppppppppppppppppppp 

Q. 8 . When loop looses its stop value then it is called I. Odd loop II. Even loop III. Unknown loop IV. User friendly loop 
a . only I 
b . I & III 
c . III & IV 
d . II & IV 

Q. 9 . Find the correct output void main() { int x=10,y=20,p,q; p=add(x,y); q=add(x,y); printf("%d %d",p,q); } add(int a,int b) { a+=a; b+=b; return(a); return(b); } 
a . 10 10 
b . 20 20 
c . 10 20 
d . 20 10 

Q. 10 . Find out the output main() {
int a[5] = {1,2,3,4,5}; int *ptr = (int*)(&a+1); printf("%d %d" ,*(a+1),*(ptr-1)); } 
a . 2 2 
b . 2 1 
c . 2 5 
d . None of the above 

Q. 11 . The area or scope of the variable depends on its 
a . Date type 
b . Storage class 
c . System type 
d . None of these 

Q. 12 . Each case statement in switch is separated by 
a . break 
b . continue 
c . exit() 
d . goto 

Q. 13 . Find out the output main() { const int x=get(); printf("%d",x); } get() { return(20); } 
a . 20 
b . Garbage value 
c . Error 
d . 0 

Q. 14 . Find out the output void main() { int a[5]={1,2,3}; int j; for(j=0;j<5;j++) x1="5.74,x2="23.78;" x1="5.74" x2="23.78" opname =" Xstr(OP);" p="c;" p="lakshya" x="10;" x="callme(x);" i="5;" x="x/2-3;" s="¶\dx¶;" i="2;">>1) { default: i++; case 1: ; case 2: ; } printf("%d",i); }
a . 2 
b . 1 
c . Expression syntax error 
d . None of these 

Q. 29 . Find the correct output void main() { int a,b,c; c=scanf("%d%d",&a,&b); printf("\n%d",c); } 
a . 1 
b . 2 
c . 0 
d . None of these 

Q. 30 . Which of the following is known as auxillary memory? 
a . RAM 
b . ROM 
c . HARD DISK 
d . BIOS

MCQ of c programming 4
Q. 1 . Choose the wrong one 
a . A structure can be nested within same structure 
b . A value of one structure variable can be assigned to another structure variable of same or different type. 
c . It is illegal to use the structure itself as its member. 
d . In self referential structure one member must be a pointer type. 

Q. 2 . Find out the output void main() { register int x; scanf("%d",&x); printf("%d",x); } If the value x is given 5 then output will be 
a . 5 
b . 0 
c . Garbage 
d . Error 

Q. 3 . Find the output #define float int
void main() { int x=10; float y=3; y=x%y; printf("%f",y); } 
a . 0 
b . 1 
c . 1.000000 
d . Error, floating point format not linked 

Q. 4 . Which of the following is a miscellaneous directive? 
a . #undef 
b . #error 
c . #elif 
d . #include 

Q. 5 . State the correct statement. 
a . Linker combines different source files before compilation. 
b . Linker combines different object files before execution. 
c . Linker expands different source files before compilation. 
d . none of these 

Q. 6 . Find out the output. void main() { int n=5; if(n==5?printf("Hallo"):printf("Hai"),printf("Bye")); } 
a . HalloBye 
b . Hallo 
c . Expression syntax error 
d . HaiBye 

Q. 7 . Find the output int x,y; void main() { show(&x,&y); printf("%d %d",x,y); } show(int *x,int *y) { *x++; *y++; } 
a . 0 0 
b . 1 1 
c . Garbage output 
d . None of these

Q. 8 . The different models used to organize data in the secondary memory are collectively called as 
a . File structures 
b . Data structures 
c . Self referential structures 
d . None of these 

Q. 9 . Find the output void main() { printf("%f",(float)9/5); } 
a . 1.8 
b . 1.0 
c . 2.0 
d . None of these 

Q. 10 . Find out the output void main() { int static auto x; x=5; printf("%d",++x); x--; printf("%d",x); } 
a . Too many storage classes in declaration 
b . 6 5 
c . 6 6 
d . None of these 

Q. 11 . Find the output. void main() { int x=5; char a[x]={μa¶,¶b¶,¶d¶}; printf("%c",++1[a]); } 
a . b 
b . c 
c . d 
d . None of these 

Q. 12 . Addresses in Memory always stored in ABCD order but data is stored in 
a . ABCD order 
b . DCBA order 
c . Depends on system type 
d . None of these 

Q. 13 . A bit field can be of 
a . int
b . float 
c . double 
d . All of these 

Q. 14 . The synonym for an existing data type can be created using 
a . typedef 
b . structure 
c . enum 
d . All of the above 

Q. 15 . Which of the following is best suited for memory optimization 
a . Union 
b . Self referential structure 
c . Array 
d . Linked list 

Q. 16 . Find out the output #include"fcntl.h" #include"sys\stat.h" void main() { int x; x=open("raja.txt",O_CREATO_TEXT, S_IWRITE); printf("%d",x); } 
a . 5 
b . 6 
c . 7 
d . None of these 

Q. 17 . All structure variables are created in 
a . Code area 
b . Stack area 
c . Uninitialized data area 
d . Initialized data area 

Q. 18 . Cast operator returns 
a . Lvalue 
b . Rvalue 
c . Integral value 
d . None 

Q. 19 . Find the output void main() { int i; for(i=1;i<=3;i++) { print: printf("C"); printf("%d",i); } } 
a . Error,':' tag not allowed within the loop 
b . 1 2 3 
c . C 1 C 2 C 3 
d . Garbage value 

Q. 20 . Find the correct output void main() { int i=100; float f=5.413; print(i,f); } print(i,f) { printf("%d %f",i,f); } 
a . 100 5.413 
b . 100 5.000 
c . 100 0.000
d . Error 

Q. 21 . Find out the output void main(void) { char numbers[5][6]={"Zero","One","Two","Three","Four"}; int *ptr=(int *)numbers; for(;*ptr!=0;) printf("%c",*ptr++); } 
a . eoOeToTreFu 
b . Zero 
c . Zr 
d . Compile time error 

Q. 22 . Find out the output void main() { int a[]={1,2,3,4,5}; int j; for(j=0;j<5;j++) x="10,y;" y="choose(x);">=5) return(y); else return(0); } 
a . 10 
b . 0 
c . Can¶t determine 
d . Error 

Q. 24 . Find the correct output #define div(x) x/x void main() { printf("%d",div(16)*16); } 
a . 1 
b . 16 
c . 256 
d . None of these 

Q. 25 . What is the formula to find real address from 16-bit physical address? 
a . segment address*16+offset address 
b . segment address+offset address *16 
c . segment address*10+offset address 
d . segment address+offset address *10 

Q. 26 . Which of the following function is appropriate to read one character at a time? 
a . fscanf() 
b . fgetc() 
c . read() 
d . fgets() 

Q. 27 . Find the correct output void main() { int a; char b; float c; printf("%d",sizeof(a+sizeof(b+c)); } 
a . 2 
b . 1 
c . 4
d . Error 

Q. 28 . Find the output. void main() { int x=5; for (;x<=5;if(x==5)) printf("%d",++x); } 
a . 5 
b . 6 
c . Error 
d . No output 

Q. 29 . Find the output void main() { int i=- 3,j=2,k=0,m; m=++i && j++ && ++k; printf("\n%d, %d, %d, %d",i,j,k,m); } 
a . -2,-3, 1,1 
b . -3, 2, 0,1 
c . -2, 3, 0,1 
d . -2, 3, 1,1 

Q. 30 . Find out the output. void main() { char *s="Rani"; printf("%s\r%s",s,s); } 
a . Rani 
b . RaniRani 
c . Rani\0 
d . Ranii 

MCQ of c programming 5 

Q. 1 . Choose the wrong one 
a . A structure can be nested within same structure 
b . A value of one structure variable can be assigned to another structure variable of same or different type. 
c . It is illegal to use the structure itself as its member. 
d . In self referential structure one member must be a pointer type. 

Q. 2 . Find out the output void main() { register int x; scanf("%d",&x); printf("%d",x); } If the value x is given 5 then output will be 
a . 5 
b . 0 
c . Garbage 
d . Error 

Q. 3 . Find the output #define float int void main() { int x=10; float y=3; y=x%y; printf("%f",y); } 
a . 0 
b . 1 
c . 1.000000 
d . Error, floating point format not linked 

Q. 4 . Which of the following is a miscellaneous directive? 
a . #undef 
b . #error 
c . #elif 
d . #include 

Q. 5 . State the correct statement. 
a . Linker combines different source files before compilation. 
b . Linker combines different object files before execution. 
c . Linker expands different source files before compilation. 
d . none of these 

Q. 6 . Find out the output. void main() { int n=5; if(n==5?printf("Hallo"):printf("Hai"),printf("Bye")); } 
a . HalloBye 
b . Hallo 
c . Expression syntax error 
d . HaiBye 

Q. 7 . Find the output int x,y; void main() { show(&x,&y); printf("%d %d",x,y); } show(int *x,int *y) { *x++; *y++; } 
a . 0 0 
b . 1 1 
c . Garbage output 
d . None of these 

Q. 8 . The different models used to organize data in the secondary memory are collectively called as 
a . File structures 
b . Data structures 
c . Self referential structures 
d . None of these 

Q. 9 . Find the output void main() { printf("%f",(float)9/5); } 
a . 1.8 
b . 1.0 
c . 2.0 
d . None of these 

Q. 10 . Find out the output void main() { int static auto x; x=5; printf("%d",++x); x--; printf("%d",x); } 
a . Too many storage classes in declaration 
b . 6 5 
c . 6 6 
d . None of these 

Q. 11 . Find the output. void main() { int x=5; char a[x]={μa¶,¶b¶,¶d¶}; printf("%c",++1[a]); } 
a . b 
b . c 
c . d 
d . None of these 

Q. 12 . Addresses in Memory always stored in ABCD order but data is stored in 
a . ABCD order 
b . DCBA order 
c . Depends on system type 
d . None of these 

Q. 13 . A bit field can be of 
a . int 
b . float 
c . double 
d . All of these 

Q. 14 . The
synonym for an existing data type can be created using 
a . typedef 
b . structure 
c . enum 
d . All of the above 

Q. 15 . Which of the following is best suited for memory optimization 
a . Union 
b . Self referential structure 
c . Array 
d . Linked list 

Q. 16 . Find out the output #include"fcntl.h" #include"sys\stat.h" void main() { int x; x=open("raja.txt",O_CREATO_TEXT, S_IWRITE); printf("%d",x); } 
a . 5 
b . 6 
c . 7 
d . None of these 

Q. 17 . All structure variables are created in 
a . Code area 
b . Stack area 
c . Uninitialized data area 
d . Initialized data area 

Q. 18 . Cast operator returns 
a . Lvalue 
b . Rvalue 
c . Integral value 
d . None 

Q. 19 . Find the output void main() { int i; for(i=1;i<=3;i++) { print: printf("C"); printf("%d",i); } } 
a . Error,':' tag not allowed within the loop 
b . 1 2 3 
c . C 1 C 2 C 3 
d . Garbage value 

Q. 20 . Find the correct output void main() { int i=100; float f=5.413; print(i,f); } print(i,f) { printf("%d %f",i,f); } 
a . 100 5.413 
b . 100 5.000 
c . 100 0.000 
d . Error 

Q. 21 . Find out the output void main(void) { char numbers[5][6]={"Zero","One","Two","Three","Four"}; int *ptr=(int *)numbers; for(;*ptr!=0;) printf("%c",*ptr++); } 
a . eoOeToTreFu 
b . Zero 
c . Zr 
d . Compile time error 

Q. 22 . Find out the output void main() { int a[]={1,2,3,4,5}; int j; for(j=0;j<5;j++) x="10,y;" y="choose(x);">=5) return(y); else return(0); } 
a . 10 
b . 0 
c . Can¶t determine 
d . Error 

Q. 24 . Find the correct output #define div(x) x/x void main() { printf("%d",div(16)*16); } 
a . 1 
b . 16 
c . 256 
d . None of these 

Q. 25 . What is the formula to find real address from 16-bit physical address? 
a . segment address*16+offset address 
b . segment address+offset address *16 
c . segment address*10+offset address 
d . segment address+offset address *10

Q. 26 . Which of the following function is appropriate to read one character at a time? 
a . fscanf() 
b . fgetc() 
c . read() 
d . fgets() 

Q. 27 . Find the correct output void main() { int a; char b; float c; printf("%d",sizeof(a+sizeof(b+c)); } 
a . 2 
b . 1 
c . 4 
d . Error 

Q. 28 . Find the output. void main() { int x=5; for (;x<=5;if(x==5)) printf("%d",++x); } 
a . 5 
b . 6 
c . Error 
d . No output 

Q. 29 . Find the output void main() { int i=- 3,j=2,k=0,m; m=++i && j++ && ++k; printf("\n%d, %d, %d, %d",i,j,k,m); } 
a . -2,-3, 1,1 
b . -3, 2, 0,1 
c . -2, 3, 0,1 
d . -2, 3, 1,1 

Q. 30 . Find out the output. void main() { char *s="Rani"; printf("%s\r%s",s,s); } 
a . Rani 
b . RaniRani 
c . Rani\0 
d . Ranii 

MCQ of c programming 6 

Q. 1 . How many times the loop will be executed? void main() { char c; for(c=1;c<=127;c++) printf("Lakshya"); } 
a . 127 times 
b . 126 times 
c . Only once 
d . None of these 

Q. 2 . Find the correct output void main() { int a[]={1,2,3,4,5}; int *p=(int *)(&a+1); printf("%d %d",*(a+1),*(p-1)); } 
a . 2 0 
b . 1 0 
c . 2 5 
d . 1 garbage 

Q. 3 . Find the output void main() { char *p="hello"; printf ("%.3s", p); } 
a . hel 
b . llo 
c . 3hello 
d . None of these 

Q. 4 . put these stages of compilation in order, 
a) link 
b) compilation 
c) execute 
d) Precompilation 
a . a,b,c,d b . d,b,a,c c . d,c,b,a d . a,c,b,d 

Q. 5 . Find the correct output void main() { struct node { int data; struct node *link; }; struct node *p,*q; p=malloc(sizeof(struct node)); q=malloc(sizeof(struct node)); printf("%d %d",sizeof(p),sizeof(q)); } 
a . 4 4 
b . 2 2 
c . 1 1 
d . None of these 

Q. 6 . Size of the physical address of 80x86 microprocessor is 
a . 16 bits 
b . 20 bits 
c . 24 bits 
d . 32 bits 

Q. 7 . Find the output void main() { int x=2,y=3,z; z=x++y++&&x++; printf("%d %d %d",x,y,z); } 
a . 3 3 1 
b . 4 4 1
c. 4 3 1 
d . None of these 

Q. 8 . Find the correct output void main () { for(clrscr();printf ("CITE");getch()) {} } 
a . Print CITE infinite times 
b . Print CITE for one time 
c . Print CITE as long as long as a keyboard is hit 
d . Print CITE for one time then print some garbage values. 

Q. 9 . Find out the output void paws(int *apple,int *ball) { *apple=*apple+*ball; *ball=*apple- *ball; *apple=*apple-*ball; } void main() { int apple=3617283450; int ball=3617283449; paws(&apple,&ball); printf("%d %d",apple,ball); } 
a . 23929 23930 
b . 23322 23323 
c . 23939 23940 
d . Error 

Q. 10 . What happens when far address is incremented? 
a . Only segment address is incremented. 
b . Only offset address is incremented. 
c . Both segment and offset address are incremented. 
d . None of these 

Q. 11 . Find out the output void main() { char *p="rama"; char *q=0; char *r="\bsita"; strcpy(q,p); strcat(q,r); printf("%s",q); } 
a . ramsita 
b . ramasita 
c . rama\sita 
d . None of these 

Q. 12 . Find the output. void main() { int a=4,b=5; printit(a, b); } printit(int b, int a) { printf("%d %d", a, b); { int a=0; int b=1; printf("%d %d", a, b); } } 
a . 4 5 0 1 
b . 5 4 0 1 
c . 5 4 5 4 
d . None of these 

Q. 13 . Find out the output. void main() { int a=5,b=7; int *p; p=&a; p--; *p=10; printf("%d %d",a,b); } 
a . 5 7 
b . 5 10 
c . 10 7 
d . Garbage 7 

Q. 14 . The address of all ISR is kept in 
a . IVT 
b . Page table 
c . Segmentation table 
d . None of these 

Q. 15 . Find the output. void main() { int x=5,y=6; do{ x=x+y; y=x-y; x=x-y; }while(x=0) j++; } 
a . 5 times 
b . 6 times 
c . Infinite times 
d . None of these 

Q. 30 . Find out the output void main() { printf("%u",main); } 
a . Garbage value 
b . Run time error 
c . Printing starting address of function main 
d . Infinite loop 

MCQ of c programming 7

Q. 1 . Find the correct output 1.#define p 2*2 2. void main() 3. { 4. #define p 4*4
5. printf("%d",p); 6. } 
a . Error: In line no.1 
b . Error: In line no.4 
c . 4 
d . 16 

Q. 2 . Find the correct output void main() { int p=7,q=9; p=p^q; q=q^p; printf("%d %d",p,q); } 
a . 7 9 
b . 9 7 
c . 18 9 
d . 14 7 

Q. 3 . which of the following is a Manifest? 
a . #define Lakshya 15 
b . #defin Lakshya 15 
c . #define Lakshya =15 
d . #define Lakshya 15; 

Q. 4 . Find out the output void main() { float x=2.8,y=4; if(x%=y) printf("Both are equal"); else printf("Not equal"); } 
a . Both are equal 
b . Not equal 
c . Error 
d . None of these 

Q. 5 . Find the correct output void main() { int a=2,b=0,c=-2; if(b,a,c) printf("Lack of C knowledge"); else printf("Beginner"); } 
a . Lack of C knowledge 
b . Beginner
c . Compile time error 
d . Run time error 

Q. 6 . Find the correct output #define SWAP(type,i,j) {type t=i;i=j;j=t;} void main() { int s=5,t=2; SWAP(int,s,t); printf("%d %d",s,t); } 
a . 5 2 
b . 2 5 
c . 5 5 
d . None 

Q. 7 . Find the correct output void main() { struct stu { int roll; char name[10]; }; struct stu s={10,"Tuni"}; call(s); } call(struct stu s) { printf("%d %s",s.roll,s.name); } 
a . 10 Tuni 
b . Compilation Error 
c . Runtime Error 
d . None of these 

Q. 8 . Find the o/p void main() { int x=5,y=3; if(x>y) printf("HOT"); else; printf("COLD"); } 
a . HOT 
b . COLD 
c . HOTCOLD 
d . Compilation error 

Q. 9 . The main function of shared memory is to
a . use primary memory efficiently. 
b . do inter process communication. 
c . do intra process communication. 
d . none of these 

Q. 10 . Switch case is very useful in 
a . Yes-no problem 
b . Menu-driven program 
c . Game programming 
d . All the above 

Q. 11 . Find out the output. #define PR(x) printf("%d ",x); #define NULL printf("error"); #define PRINT(x1,x2) PR(x1); PR(x2); NULL void main() { int x=5,y=10; PRINT(x,y); } 
a . 5 10 error 
b . 10 5 error 
c . 5 10 
d . 10 5 

Q. 12 . Find the output #define MAX(x,y) x>y?x:y void main() { int x=2,y=3; printf("%d",MAX(++x,++y)); } 
a . 4 
b . 5 
c . Error 
d . None of these 

Q. 13 . Find out the output void main() { unsigned int a=65536; if(!a) printf("%d",a,++a); else printf("%d",a,++a); } 
a . 0 
b . 1 
c . 65536 
d . 65537 

Q. 14 . x%y is equal to
a . y-(x/y)*x 
b . x-(x/y)*y 
c . x-(y/x)*x 
d . y-(y/x)*y 

Q. 15 . #define dprintf(e) printf(#e " = %d\n",'e') void main() { int x=8; int y=3; dprintf(x/y); } 
a . expr=2 
b . expr=101 
c . x/y=101 
d . None of the Above. 

Q. 16 . Find out the output void main() { int x=6,y=4,z=0; if((x>=y)(z=y)) z-=2; printf("%d",z); } 
a . 0 
b . 2 
c . -2 
d . None of these 

Q. 17 . Self referential structure 
a . Used to create a memory link. 
b . Plays an important role in linked list creation. 
c . Contains the object of same structure which is of pointer type. 
d . All the above 

Q. 18 . Find out the output typedef struct boy { float height; char name:9; int age:16; }boy; void main() { boy b={5.8,"Praveen kumar",24}; printf("%f %s %d",b.height,b.name,b.age); } 
a . 5.8 Praveen k 24 
b . 5.8 Praveen kumar 24
c . 5.8 Praveen k 16 
d . None of these 

Q. 19 . Switch-case statement does not implement on 
a . non exclusive case 
b . mutually exclusive case 
c . mutually non exclusive case 
d . exclusive case 

Q. 20 . Find out the output void main() { unsigned int i=2; i=(((i<<6)-1)^127); i="15;">y? x:y void main() { int a,b; a=MAX(1,2)+3; b=MAX(4,3)+5; printf("%d %d",a,b); } 
a . 5 4 
b . 5 9 
c . 5 8 
d . None of these 

Q. 24 . Find the output void main() { *(char*)65=¶a¶; printf ("%c",*(char*)65); } 
a . a 
b . A
c . Error 
d . None of these 

Q. 25 . The function ftell(fp) returns 
a . The beginning position of the file represented by fp. 
b . The end position of the file represented by fp. 
c . The current position of the file represented by fp. 
d . None of these 

Q. 26 . Find out the output void paws(int *apple,int *ball) { *apple=*apple+*ball; *ball=*apple-*ball; *apple=*apple-*ball; } void main() {
int apple=3617283450; int ball=3617283449; paws(&apple,&ball); printf("%d %d",apple,ball); } 
a . 23929 23930 
b . 23322 23323 
c . 23939 23940 
d . Error 

Q. 27 . Find the correct output void main() { char a[4]="rama"; char b[]="shyama"; printf("%d %d", sizeof(a),sizeof( b)) ; } 
a . 4 7 
b . 5 6 
c . 5 7 
d . 4 6 

Q. 28 . Find the correct output typedef struct tag { int i; char c; }tag; void main() { struct tag t1={1,¶C¶}; tag t2={2,¶A¶}; printf("%d%c ",t1.i,t1.c); printf("%d%c ",t2.i,t2.c); } 
a . Error in first printf() statement. 
b . Error in second printf() statement. 
c . 1C 2A 
d . None of these 

Q. 29 . Find the correct output void main() { int i=5; i=++i + ++i + i++; printf("%d",i); } 
a . 21 
b . 22 
c . 19
d . None of these 

Q. 30 . What will be the value of μx¶ after execution of the following program? void main() { int x=!0*20; } a . 10 
b . 20 
c . 1 
d . 0

MCQ of c programming 7
Q. 1 . Find the correct output void main() { void show(); show(); } void show() { char c[]="Lakshya\0\0"; int i,*p; p=c; for(i=0;*p;i++) printf("%c",*p++); } 
a . Lakshya0 
b . Lkha 
c . Lkha0 
d . Error 

Q. 2 . Find the output void main() { int x=2,y=3,z; z=x++y++&&x++; printf("%d %d %d",x,y,z); } 
a . 3 3 1 
b . 4 4 1 
c . 4 3 1 
d . None of these 

Q. 3 . An I/O stream is 
a . a text stream 
b . a binary stream
c . Both a and b 
d . None of these 

Q. 4 . Find out the output void main() { int k=2,j=3,p=0; p=(k,j,k); k=p; j=k; printf("%d\n",p); } 
a . 2 
b . Error 
c . 0 
d . 3 

Q. 5 . Find the output. void main() { int x=5,y=6; change(&x, &y); printf("%d %d", x, y); } change(int *x, int *y) { int temp=1; temp^=*x; *x^=*y; *y^=temp; } 
a . 5 6 
b . 6 5 
c . 3 2 
d . None of these 

Q. 6 . Which of the following is an optical ROM? 
a . ROM 
b . PROM 
c . EPROM 
d . CDROM 

Q. 7 . Find out the output void e(int ); main() { int a; a=3; e(a); } void e(int n)
{ if(n>0) { e(--n); printf("%d" , n); e(--n); } } 
a . 0 1 2 0 
b . 0 1 2 1 
c . 1 2 0 1 
d . 1 2 0 1 

Q. 8 . Find the output. void main() { int array[]={1,3,5,7,9},*p,i; p=array[0]; for(i=0;i<5;i++) c="65;" c="(!="c);" c="scanf(" y="Academy" i="3;i">=1;i--) for(j=i;j>=1;j--) printf("%d",i); } 
a . 321211 
b . 333221 
c . 332211 
d . 123233 

Q. 15 . Find the incorrect one for μtypedef ¶ srorage class 
a . Permits descriptive names for datatypes. 
b . Renaming existing datatype 
c . Modification of the program is easier when host machine is changed. 
d . All of the above 

Q. 16 . Find the output void main() { printf("%d %d",sizeof(μa¶), sizeof(μa1¶)) ; } 
a . 1 2 
b . 1 1 
c . 2 1 
d . None of these 

Q. 17 . Find the correct output void main() { int a=2,b=4,c; c=a>b?printf("2>=4"):puts("2<4");>=4 b . 2<4 a="100;" i="0;i<3;i++);" x="5;">
void main() { unsigned int a=-1; printf("%d",~1); } 
a . -3 
b . -1 
c . -2 
d . 1 

Q. 29 . Which of the following is/are numeric type constants? 
a . integer constant and character constant 
b . integer constant and floating-point constant 
c . character constant and floating-point constant 
d . character constant and string constant 

Q. 30 . Find the correct output void main() { struct emp { int eid; char ename[20]; }; struct emp e={010,"Deepak"}; show(s); } show(struct{int eid;char ename[20];}e) { printf("%d %s",e.roll,e.name); } 
a . Compilation Error 
b . 010 
c . 010 Deepak 
d . None of these 

MCQ of c programming 8
Q. 1 . void main() { int i,j; for(i=0,j=0;i<2,j<2;i++,j++) i="5;" a="1,b="2;" a="="2)" b="="3)" x="2,y="3;" t="x;" x="*y;" y="t;" i="9;" i="0;i<3;i++)" x="3.7;" y="1.5;">1.5) printf("fool"); else printf("stupid"); } 
a . fool 
b . stupid
c . garbage value 
d . None of these 

Q. 11 . Most of the errors blamed on a computer are actually due to 
a . programming errors 
b . hardware damage 
c . data entry errors 
d . physical conditions 

Q. 12 . Find the output. void main() { int i; for(i=-9;!i;i++); printf("%d",-i); } 
a . 8 
b . 9 
c . 0 
d . 1 

Q. 13 . Switch-case statement does not implement on 
a . non exclusive case 
b . mutually exclusive case 
c . mutually non exclusive case 
d . exclusive case 

Q. 14 . Find out the output. void main() { int i=98; while(100-i++) printf("%u",i); switch(i) case μe¶: printf("Fool"); } 
a . 98 99 100 
b . 99 100 
c . 99 100 Fool 
d . Expression syntax error 

Q. 15 . Find out the output void main() { if("lakshya"=="lakshya") printf("equal"); else printf("not equal"); } 
a . equal
b . not equal 
c . Compile time error 
d . None of these 

Q. 16 . Find the output. void main() { char s=¶A¶; char a=¶a¶; printf("%d",s-a); } 
a . -32 
b . -18 
c . Error 
d . None of these 

Q. 17 . Find out the true statement. 
a . A union variable can be assigned to another union variable. 
b . The address of union variable can be extracted by using & operator. 
c . A function can return a pointer to the union. 
d . All the above 

Q. 18 . Find out the output #define min(a,b) ((a)<(b))?(a):(b) main() { int i=0,a[20],*ptr; ptr=a; while(min(ptr++,&a[9])<&a[8]) i=i+1; printf("i=%d\n",i); } 
a . 7 
b . 6 
c . 5 
d . compile time erro 

Q. 19 . To flush all output streams we can write 
a . fflush(stdout) 
b . fflush(NULL) 
c . fflush(ALL) 
d . None of these 

Q. 20 . Find the correct output void main() { int a[]={1,2,3,4,5},i; for(i=0;i<5;i++) p="hai" p="¶H¶;" q="¶B¶" a="10;" a="(*a)*(*a);" x="12;" y="x;" i="1;" c="¶l¶;" p="strchr(s,c);" x="(y="3,y+1);" a="5,b="4,c="10;">b) ? &a : &b) = (a+b>c); printf("%d\t%d",a,b); } 
a . 5 4 
b . Error, lvalue required 
c . 0 4 
d . 4 0 

MCQ of c programming 9
Q. 1 . Find the correct output void main() { int i; for(i=1;i<=3;i++) { if(i==3) break; printf("%d",i); } for(i=1;i<=3;i++) { if(i==3) goto last; printf("%d",i); } end: ; } 
a . 123123 
b . 1212 
c . Error 
d . Garbage values 

Q. 2 . Which member of a union is in use at any time can be known explicitly using 
a . Enum 
b . Bit fields 
c . Static members 
d . Can¶t be
determined 

Q. 3 . The Turbo C implementation of C language supports 
a . High level file I/O 
b . System level file I/O 
c . Both a and b 
d . Executable files only 

Q. 4 . The commonly used functions for writing to a text stream are 
a . putc() 
b . fputc() 
c . fputs() 
d . All of the above 

Q. 5 . A bit field can be of 
a . int 
b . float 
c . double 
d . All of these 

Q. 6 . An assembler which runs on a computer for which it produces object codes is called as 
a . one pass assembler 
b . two pass assembler 
c . self assembler 
d . none of these 

Q. 7 . Find the output void main() { char a=¶H¶; switch(a) { case μH¶:printf("%c",¶H¶); case μE¶:printf("%c",¶E¶); case μL¶:printf("%c",¶L¶); case μL¶:printf("%c",¶L¶); case μO¶: printf("%c",¶O¶); } } 
a . HELLO 
b . HEL 
c . Error 
d . HELO 

Q. 8 . Width of a data bus of the microprocessor is known as 
a . Byte Regs 
b . Word Regs 
c . WordLength 
d . None 

Q. 9 . Find the output void main() { char *p= (char*) 0x21; printf ("%d %p", p, p); } 
a . 21 0021 
b . 21 21 
c . 33 0021 
d . None of these 

Q. 10 . In a hard disk a track is a collection of 
a . sectors 
b . clusters 
c . cylinders 
d . none of these 

Q. 11 . Find the output. void main() { int a=5; a=find(a+=find(a++)); printf("%d", a); } int find(int a) { return ++a; } 
a . 12 
b . 13 
c . 15 
d . None of these 

Q. 12 . Find the correct output void main() { printf("%d","lakshya"[1]); } 
a . l 
b . a 
c . 97 
d . None of these 

Q. 13 . Find the output. union res { int a:16; char b:10; } void main() { union res s; s.b=¶B¶; s.a=10; printf("%c %d", s.b, s.a) ; } 
a . 2048 10 
b . B 2144 
c . B 10 
d . None of these 

Q. 14 . Find out the output. void main() { char *s="Rani"; printf("%s\r%s",s,s); } 
a . Rani 
b . RaniRani 
c . Rani\0 
d . Ranii 

Q. 15 . Find the output void main() { int i; static int j=0; for(i=1;i<5;i++) num="345," sum="0;" m="num%10;" num="num/10;" sum="sum*10+m;" a="*a+*b;*b="*a-*b;*a="*a-*b;" x="10,y="20;" x=" %d" y =" %d\n" x="10" y="20" x="20" y="10" x="garbage" y="garbage" a="sizeof(int)/sizeof(float))" a="="1.000000)" i="10;" p="&i;" q="p;" a="2,b="4,c;" c="a">b?printf("2>=4"):puts("2<4");>=4 b . 2<4 x="16384,y="1;" i="3,j="3,k;" k="lakshya(++i)*++i;" p="a;" i="0;i<="2;i++)" j="2;printf(" c="a;" i="1;i<5;i++)" s="{80," a="3,b="6;" a="b);" x="10;" y="3.14;" x="20;" a="4,b="5,ar[2];" f="0.9;" d="0.9f;" f="="d)" i="1,j="2,k="3;" i="="1)" j="="2)" k="="3)" p="array[0];" i="0;i<5;i++)" i="4;i">0;) printf("%d",a[i--]); } 
a . 05432 
b . 54321 
c . 5432 
d . 4321 

Q. 26 . Which of the following is/are true for nested if
I. It can only test for equality. 
II. Conditions may be repeated for number of times. 
III. It can evaluate relational or logical expressions. 
IV. Character constants are automatically converted to integers. 
a . All of the above 
b . I & II 
c . I, II & III 
d . II, III & IV 

Q. 27 . Most of the errors blamed on a computer are actually due to 
a . programming errors 
b . hardware damage 
c . data entry errors 
d . physical conditions 

Q. 28 . Find the correct output struct abc { int x; char c; union xyz { int a; char b; float c; }p; }q; void main() { printf("%d",sizeof(q)); } 
a . 2 
b . 4 
c . 7 
d . None of these 

Q. 29 . Find the output void main() { int *q,**p,x=4; q=&x; p=&q; (**p)++; ++*p; printf("%d",**p); } 
a . 5 
b . 6 
c . Garbage output
d . Error, non portable pointer conversion 

Q. 30 . Which storage class can precede any data type in the parameter list? 
a . Auto 
b . Static 
c . Register 
d . Extern

MCQ of c programming 11

Q. 1 . Find the output void main() { int i=4,j=-3; mul(&i,j); printf("%d %d",i,j); } mul(int *a,int b) { a=*a**a; b=b*b; } 
a . 4 3 
b . 4 9 
c . 16 -3 
d . 16 9 

Q. 2 . Find the output. void main() { unsigned long i=40000; printf("%l", i); } 
a . %l 
b . 40000 
c . Garbage 
d . No output 

Q. 3 . Find out the output void main() { static int x=4,y=5; callme(x,y); } callme(static int x,static int y) {
x=y; y=x; printf("%d %d",x,y); } 
a . 4 5 
b . 5 5 
c . Error 
d . None of these 

Q. 4 . State the correct statement. 
a . Nested union is not possible. 
b . Self referential union is possible 
c . Different interpretations for the same memory location are possible in structure. 
d . Both a and c 

Q. 5 . Find out the output void main() { printf("%d",(4,7,11)-(6,5,12)); } 
a . 5 
b . -2 
c . -1 
d . None of these 

Q. 6 . Find out the output void main() { int i=0; ((i--,++i)!=0); i-=i++; i+=i++; printf("i=%d",i); } 
a . 3 
b . 2 
c . 1 
d . Error 

Q. 7 . The default initial value of malloc() memory allocation is 
a . Garbage 
b . Zero 
c . Can¶t say 
d . None of these 

Q. 8 . Which of the file extensions is used as executable file? 
a . .EXE 
b . .COM 
c . .BAT 
d . all the above

Q. 9 . Find the output #define ABC(x) printf("%d",x);\ printf("%0",x); void main() { int x=12; ABC(x) } 
a . 1214 
b . 1212 
c . 12 
d . Error 

Q. 10 . Find the output. void main() { int array[]={1,3,5,7,9},*p,i; p=array[0]; for(i=0;i<5;i++) a="15;" date="{&a," p="&date;">p); 10. } 
a . Line no.8 
b . Line no. 9 
c . Line no.6 
d . None 

Q. 12 . Find the correct output void main() { int a=2,b=5; if(a,b,0) printf("Norton"); else printf("Avast"); } 
a . Norton 
b . Avast 
c . Compilation error 
d . None of these 

Q. 13 . Find the output void main() { while(!"") { printf("Hello"); } } 
a . Prints Hello infinite times 
b . Hello 
c . Error
d . No output 

Q. 14 . Find out the output void main() { char a[]="abcde"; char *p=a; p++; p++; p[2]='z'; printf("%s",p); } a . zde 
b . cdz 
c . abzde 
d . abz 

Q. 15 . Find the correct output void main() { char a[][9]={"Lakshya","Advance","C","Training","Java"}; printf("%c %s in %s",a[2][0],&a[3][0],&a[0][0]); } 
a . CT in L 
b . C in Lakshya 
c . C Training in Lakshya 
d . Error 

Q. 16 . The pointer which is created in data segment and holds the address of base location is known as 
a . Near pointer 
b . Bad pointer 
c . Smart pointer 
d . None of these 

Q. 17 . State the correct statement. 
a . A for loop may be nested in a while loop. 
b . A do-while loop may be nested in a for loop 
c . A while loop may be nested in a for loop 
d . All the above 

Q. 18 . Find out the output void main() { int a=1,b=2,c=3; scanf("%d %*d %d",&a,&b,&c); printf("a=%d b=%d c=%d",a,b,c); } [ NOTE : 3 values entered by the user are:100 200 300 ] 
a . a=1 b=2 c=3 
b . a=100 b=200 c=300 
c . a=100 b=200 c=3
d . a=100 b=300 c=3 

Q. 19 . What is the format specifier of long double? 
a . %ld 
b . %id 
c . %lf 
d . %g 

Q. 20 . What is the format specifier of long double? 
a . %ld 
b . %id 
c . %lf 
d . %g 

Q. 21 . Find the correct output void main() { int i=1; i=(5>2)?printf(""Rama):printf("Shyama"); printf("%d",i); } 
a . Rama1 
b . Rama4 
c . Rama0 
d . None of these 

Q. 22 . int far **p, here p is a 
a . Far pointer holds address of another far pointer. 
b . Near pointer holds address of another far pointer. 
c . Far pointer holds address of another near pointer. 
d . Near pointer holds address of another near pointer. 

Q. 23 . Find out the output void main() { int i; char *p="lakshya",c; while(i++printf?"cool":"fool"); } 
a . cool 
b . fool 
c . No output 
d . None of these 

Q. 30 . Find the correct output void main() { int a=0; for(a;++a;a<=100) printf("%d",a); } 
a . Print 1 to 99 infinite times 
b . Print 1 to 99 
c . Print some garbage values 
d . Infinite loop 

MCQ of c programming 12 

Q. 1 . Find out the output #include"limits.h" void main() { printf("%d",sizeof(-INT_MIN)); } 
a . 0 
b . 2 
c . 32768 
d . 65536 

Q. 2 . Find the correct output
union yyy { int i; float f; }y; void main() { y.i=23.786; printf("%d",y.i); } 
a . Error 
b . Garbage 
c . 23 
d . None of these 

Q. 3 . Find out the output. int a=6; void main() { static int *x=&a; printf("%d",*x); } 
a . 6 
b . 0 
c . Error, illegal initialization 
d . None of these 

Q. 4 . Find the output void main() { int x=5; if(x=1) printf("one"); else printf("five"); printf("%d",x); } 
a . One5 
b . Five5 
c . One1 
d . Five1 

Q. 5 . Find the output. void main() { char ch; if("printf("")") printf("Ok"); else printf("Bye"); } 
a . Ok 
b . Bye 
c . 0Ok 
d . 0Bye 

Q. 6 . Find the correct output void main() { int i=5; i=++i + --i - ++i; printf("%d",i); } 
a . 6 
b . 7 
c . 5 
d . None of these 

Q. 7 . Find the correct output void main() { int i; float f=3.14; float compute(float); i=compute(f); printf("%d",i); } float compute(float x) { if(x==3.14) return(0); else return(1); } 
a . Suffering 
b . Garbage 
c . 0 
d . 1 

Q. 8 . Find the correct output #define mul(x,y) x*y void main() { int a=5,b=6; printf("%d",mul(a+1,b-1)); } a . 10 
b . 30 
c . 35 
d . None of these 

Q. 9 . Find out the output void main() { show(5); } show(int x) { static int i=1; while(i++<5) x="5;" x="="5))" y="5;" x="come(y);" y="go(x);" p="x+3;" q="5;r="4;">r)-2]); } 
a . 4 
b . 3 
c . 5 
d . Error 

Q. 17 . The errors that can be pointed out by the compiler are 
a . syntax error 
b . semantic error 
c . logical error 
d . all the above 

Q. 18 . Find the o/p struct date { int day,month,year; } void main() { struct date today={3,7,6,2007}; printf("%d %d %d",today.day,today.month,today.year); } 
a . 3 7 6 
b . 7 6 2007 
c . Compilation error 
d . None of these 

Q. 19 . Maximum range of an integer 
a . MAX_MAX 
b . INT_MAX
c . SIZEOF_INT 
d . MAX_INT 

Q. 20 . Find the output void main() { int *p,**q,i=5; p=&i; q=p; **q=10; printf ("%d %d",*p,**q); } 
a . 5 10 
b . 10 10 
c . 5 5 
d . None of these 

Q. 21 . Recursion 
a . Execution is faster. 
b . Additional storage space is not required. 
c . A queue is needed to process the recursion. 
d . Helps in writing compact code. 

Q. 22 . Find out the false statement. 
a . The function main() returns an integer by default. 
b . A function can be a part of an expression. 
c . Size of a function can be measured using sizeof() operator. 

d . A stack frame is created in memory for each function call. 

Q. 23 . 80x86 Microprocessor wordlength is of 
a

 . 8 bits 

b . 16 bits 

c . 24 bits 

d . 32 bits 



Q. 24 . What is the octal equivalent of a decimal number (179)10 

a . (263)8 

b . (363)8 

c . (163)8 

d . (463)8 



Q. 25 . Find the output. struct st { int roll; char name[15]; }s{10,"lakshya"}; void main() { printf("%d %s", (&s)->roll,(&s)->name); } 

a . 15 lakshya 

b . Garbage lakshya
c . Garbage garbage 
d . None of these 

Q. 26 . If float and double are defined with type register the compiler treats them as 
a . Auto variables 
b . Static variables 
c . Register variables 
d . Extern variables 

Q. 27 . Find the correct output void main() { struct dist { char *c; int i; struct dist *d; }; static struct dist arr[]={{"Raipur",1,arr+1}, {"Kolapur",2,arr+2}, {"Bhabanipur",3,arr} }; struct dist *dis=arr; printf("%s",arr[(++dis)->i].c); } 
a . Kolapur 
b . Raipur 
c . Bhabanipur 
d . aipur 

Q. 28 . Find out the output void main() { char a[10]="lakshya"; int i=0,j=0; while(i<=strlen(a)) { i=j++; if(a[i]==¶a¶a[i]==¶e¶a[i]==¶i¶a[i]==¶o¶a[i]==¶u¶) { while(ip); 10. } 
a . Line no.8 
b . Line no. 9 
c . Line no.6 
d . None

Q. 1 . Find the output void main() { int x=5, *p, q;
p=&x; q=p; printf ("%d", ++*q); } 
a . 5 
b . 6 
c . Error, invalid indirection 
d . None of these 

Q. 2 . B language was developed by 
a . Dennis Ritchie in 1972 
b . Martin Richards in 1967 
c . Geoffrey brown in 1968 
d . Ken Thompson in 1970 

Q. 3 . Find the output #define float int void main() { int x=10; float y=3; y=x%y; printf("%f",y); } 
a . 0 
b . 1 
c . 1.000000 
d . Error, floating point format not linked 

Q. 4 . Find the correct output void main() { int i; float f=3.14; float compute(float); i=compute(f); printf("%d",i); } float compute(float x) { if(x==3.14) return(0); else return(1); } 
a . Suffering 
b . Garbage 
c . 0 
d . 1 

Q. 5 . The PID of the kernel process is
a . 0 
b . 1 
c . undefined 
d . 2 

Q. 6 . Which operator is used both as an operator and a keyword? 
a . Conditional operator 
b . Cast operator 
c . Sizeof operator 
d . None of these 

Q. 7 . Find the correct output void main() { int x=0; printf(x+"YUinlakshya%d",x=1); } 
a . 1 
b . YUinlakshya1 
c . Uinlakshya1 
d . Uinlakshya1 

Q. 8 . Find the correct output #define int char void main() { int a=65; printf("%d",sizeof(a)); } 
a . 1 
b . 2 
c . Garbage value 
d . None of these 

Q. 9 . Choose the appropriate one. A variable is called as 
a . Lvalue 
b . Modifiable lvalue 
c . Rvalue 

d . Modifiable rvalue 

Q. 10 . Find the output void main() { char x=¶A¶; switch(x) { if(x==A) { printf("tomtom"); } else
{ printf("tom"); default:printf("harry"); } } } 
a . tomtom 
b . harry 
c . tomharry 
d . Error 

Q. 11 . Find out the output int j=10; void main() { int j=5; static int i; i=j; printf("%d",i); } 
a . 5 
b . 10 
c . Error, illegal initialization 
d . None of these 

Q. 12 . Find out the output void fun(char**); main() { char * argv[] = { "ab" ,"cd" , "ef" ,"gh", "ij" ,"kl" }; fun( argv ); } void fun( char **p ) { char* t; t= (p+= sizeof(int))[-1]; printf( "%s" , t); } 
a . ab 
b . cd 
c . ef 
d . gh 

Q. 13 . Find the correct output void main() { char *p="abc123",*q="abc"; while(*p++=*q++) printf("%c%c",*p,*q); }
a . aabbcc 
b . bbcc112233 
c . bbcc1 
d . aabbcc123 

Q. 14 . Find the correct output void main() { char s[]="Lakshya"; printf("%c",*&*s); } 
a . Error 
b . Garbage value 
c . No output 
d . L 

Q. 15 . Find out the output void main() { int a= 0;int b = 20;char x =1;char y =10; if(x,b--,x--,x++) printf("%d",x); } 
a . 0 
b . 1 
c . 2 
d . None of the above 

Q. 16 . Find the correct output void main() { int a=9; char c; c=2*20.5+a; printf("%c",c); } 
a . a 
b . b 
c . 9 
d . Error 

Q. 17 . Find the output void main() { int x=65536,y; y=sizeof(++x); printf("%d %d",x,y); } 
a . 0 2 
b . 1 2 
c . 65536 2
d . None of these 

Q. 18 . Find out the output void main() { static char *s[ ] = {"black", "white", "yellow", "violet"}; char **ptr[ ] = {s+3, s+2, s+1, s}, ***p; p = ptr; **++p; printf("%s",*--*++p + 3); } 
a . ck 
b . te 
c . violet 
d . Error 

Q. 19 . A bit field is 
a . A pointer variable in a structure 
b . One bit or a set of adjacent bits within a word. 
c . A pointer variable in a union. 
d . None of these 

Q. 20 . Find out the output void main() { int x=10; x=callme(x); printf("%d",x); } callme(int x) { int i=5; x=x/2-3; return x,i; } 
a . 3 
b . 5 
c . Can¶t return more than one value 
d . Function should have a return type 

Q. 21 . Find the output. void main() { int x=5; void *p; p=&x; printf("%d",*(int *)p); } 
a . 5 
b . Garbage 
c . Generic pointer can not be dereferenced
d . No output 

Q. 22 . Find the output union res { char a:6; int b:8; } void main() { union res s; printf("%d",sizeof(s)); } 
a . 14 
b . 8 
c . 1 
d . 2 

Q. 23 . The function call fseek(ptr,0,0),is same as 
a . ptr=rewind(ptr) 
b . ptr=fopen() 
c . ftell(ptr) 
d . None of these 

Q. 24 . Find out the output #define CUBE(x) (x*x*x) main() { int a=3; char *b; b=&a; a=CUBE(*b++); printf("\n %d %d",a,b); } 
a . 64 4 
b . 27 4 
c . 27 6 
d . None of these 

Q. 25 . Find the correct output void main() { int i=5; i=i++ + ++i + i++; printf("%d",i); } 
a . 18 
b . 20 
c . 24 
d . None of these 

Q. 26 . Find out the output int main(void)
{ int x=256; if (*(char *)&x == 255) { printf("Little Endian\n"); } else { printf("Big Endian\n"); } return 0; } a . Big Endian 
b . Little Endian 
c . Error 
d . None of these 

Q. 27 . Find out the output. struct xyz { int xyz ; }xyz; union xyz { int xyz; }xyz; void main() { printf("%d ",xyz.xyz); } 
a . 1 
b . 0 
c . compile time error 
d . None of these 

Q. 28 . Find out the output void main() { char s[]="Lakshya"; printf("%c %c",*(&s),*(&s[0])); } 
a . L L 
b . Prints character present at whole address of s, then L 
c . La 
d . Error, lvalue required 

Q. 29 . Which of the following is a valid hexadecimal integer constant? 
a . -0xa 
b . 0x5.2
c . 0xIF 
d . all of the above 

Q. 30 . The function call fseek(ptr,0,0),is same as 
a . ptr=rewind(ptr) 
b . ptr=fopen() 
c . ftell(ptr) 
d . None of these

MCQ of c programming 14
Q. 1 . Find the correct output void main() { int a=30,b=20,c; c=(float)a/b; printf("%d",c); } 
a . 1 
b . 1.500000 
c . 1.000000 
d . Error 

Q. 2 . State the correct statement. struct employee { int eid; char name[23]; float salary; }emp={278,"p.das",5000.000},*p=&emp; How to access eid in the above structure? 
I. *p->eid 
II. p.eid 
III. (*p).eid 
IV. (*p)->eid 
a . Only I 
b . Only III 
c . Both I & III 
d . All of the above 

Q. 3 . Find out the output void main() { int ch=48; if(ch) { printf("valid"); break; } else printf("invalid"); }
a . valid 
b . invalid 
c . No output 
d . None of these 

Q. 4 . Find out the output void main() { int k=1; printf("%d==1 is ""%s",k,k==1?"TRUE":"FALSE"); } 
a . Error 
b . 1==1 is TRUE 
c . 0==1 is FALSE 
d . Garbage Output 

Q. 5 . what is the o/p in turbo compiler? struct stud { int x:18; char *y; f loat z; }s1; void main() { printf("%d",sizeof(s1)); } 
a . 7 
b . 1 
c . 8 
d . Error 

Q. 6 . Find the output void main() { int i=-3,j=2,k=0,m; m=++ && j++ && ++k; printf("\n%d, %d, %d, %d",i,j,k,m); } 
a . -2,-3,1,1 
b . -3, 2, 0,1 
c . -2, 3, 0,1 
d . -2, 3, 1,0 

Q. 7 . Find the output. void main() { int x=5,y=6; do{ x=x+y; y=x-y;
x=x-y; }while(x0) rev(--n); printf("%d",n); } 
a . 0012 
b . 123 
c . 012 
d . None of these 

Q. 9 . RAM is made up of 
a . registers 
b . diodes 
c . capacitors 
d . flip-flops 

Q. 10 . The default memory model in C is 
a . tiny 
b . small 
c . medium 
d . compact 

Q. 11 . Find the correct output void main() { int i=5; i=i++ + ++i; printf("%d",i); } 
a . 11 
b . 12 
c . 13 
d . None of these 

Q. 12 . Find out the output int i = 4; void main() { switch (i) { default: ; case 3: i += 5; if ( i == 8); { i++; if (i = 9); i *= 2; } i -= 4;
break; case 8: i += 5; break; } printf("i = %d\n", i); } 
a . i=5 
b . i=16 
c . i=18 
d . i=14 

Q. 13 . Find out the output. void main() { printf("%d",sizeof(5.3)); } 
a . 2 
b . 4 
c . 8 
d . Suffering 

Q. 14 . A file pointer is 
a . a stream pointer 
b . a buffer pointer 
c . a pointer to a FILE data type 
d . All of the above 

Q. 15 . Find out the output void main() { char p[6]; static char *q; q=p; *q="Hello"; printf("%s",q); } 
a . Garbage output 
b . Hello 
c . Error 
d . None of these 

Q. 16 . Find out the output void main() { int x[]={1,2,3,4,5,6}; int *p,q,r; p=x+3; q=5;r=4; printf("%d",p[(q>r)-2]); }
a . 4 
b . 3 
c . 5 
d . Error 

Q. 17 . What is the formula to find real address from 16-bit physical address? 
a . segment address*16+offset address 
b . segment address+offset address *16 
c . segment address*10+offset address 
d . segment address+offset address *10 

Q. 18 . The function strcmp(s1,s2) returns negative value if 
a . Length of s1 is less than s2 
b . Length of s2 is less than s1 
c . Length of s1 is less than or equal to s2 
d . Both s1 and s2 are same. 

Q. 19 . Find the output. void main() { int a,b,sum=0; sum= (a=5,b=9,++a+ ++b); printf("%d", sum); } 
a . 16 
b . 5 
c . Expression syntax error 
d . Error, lvalue required 

Q. 20 . Find out the output #define Str(x) #x #define Xstr(x) Str(x) #define OP plus void main() { int *opname = Xstr(OP); printf("%s",opname); } 
a . plus 
b . No output 
c . It will show compilation error 
d . No output 

Q. 21 . void main() { int i,j=1; for(i=1;i<5;i++) i="="2" j="="2)" i="1;" i="="2)" x="5;" temp="a;" a="b;" b="temp;" a="5,b="6,temp;"> b) swap(a,b); printf("a=%d b=%d",a,b); } 
a . a=5 b=6 
b . a=6 b=5
c . a=6 b=0 
d . None of these 

Q. 26 . Find out the output main() { static int val=7; int data; if (--val) { data=main()+val; printf("%d ",data); } return 0; } 
a . Compile time Error 
b . Infinite loop 
c . 1 2 3 4 5 6 
d . 0 0 0 0 0 0 

Q. 27 . Find out the output. void main() { int i=5,j=5; i= i++*i++*i++*i++; printf("i=%d ",i); j= ++j*++j*++j*++j; printf("j=%d",j); } 
a . i=1680 j=1680 
b . i=629 j=6561 
c . i=1681 j=3024 
d . Compile time Error 

Q. 28 . State the true statement. 
a . A circular list doesn¶t have a natural first or last node. 
b . It is always desirable keep an extra node at the front of the list. 
c . A stack can¶t be represented in memory using linear array. 
d . All of the above 

Q. 29 . Find the output #define float int void main() { int x=10; float y=3; y=x%y; printf("%f",y); } 
a . 0
b . 1 
c . 1.000000 
d . Error, floating point format not linked 

Q. 30 . Find the output void main() { int *q,**p,x=4; q=&x; p=&q; (**p)++; ++*p; printf("%d",**p); } 
a . 5 
b . 6 
c . Garbage output 
d . Error, non portable pointer conversion 

MCQ of c programming 15
Q. 1 . Find the output. void main() { int x[5]; see(x); printf("%d",x[2]); } see(int x[]) { x++; x[1]=100; } 
a . 100 
b . 0 
c . Garbage 
d . None of these 

Q. 2 . Which storage class can precede any data type in the parameter list? 
a . Auto 
b . Static 
c . Register 
d . Extern 

Q. 3 . ftell() 
a . Takes only one argument 
b . Takes two arguments 
c . Moves the file pointer only in forward direction 
d . None of these

Q. 4 . The operators [],.,-> are known as 
a . Data access operators 
b . Structure access operators 
c . Member access operators 
d . None of these 

Q. 5 . What is not possible with union? 
a . Array of union 
b . Pointer to union 
c . Self-referential union 
d . None of these 

Q. 6 . Find out the output main() { char str[5]="fast"; static char *ptr_to_array = str; printf("%s",ptr_to_array); } 
a . Compilation will only give a warning but will proceed to execute & will display "fast" 
b . Display "fast" on screen 
c . Error illegal initialization 
d . None of the above 

Q. 7 . Find the correct output void main() { struct dist { char *c; int i; struct dist *d; }; static struct dist arr[]={{"Raipur",1,arr+1}, {"Kolapur",2,arr+2}, {"Bhabanipur",3,arr} }; struct dist *dis=arr; printf("%s",arr[(++dis)->i].c); } 
a . Kolapur 
b . Raipur 
c . Bhabanipur 
d . aipur 

Q. 8 . Find the output void main() { enum color{red, green};
enum colors{green,white}; printf("%d %d",green, white); } 
a . 1 1 
b . 0 1 
c . 1 0 
d . None of these 

Q. 9 . The function unlink(filename) is used 
a . to remove link between file and buffer 
b . to remove the existing file from the directory 
c . to remove the contents of file only 
d . None of these 

Q. 10 . Find the output void main() { int i=5; for(i=-5; !!i; i++); printf("%d",-i) } 
a . 5 
b . 0 
c . -5 
d . None of these 

Q. 11 . Find the output void main() { int x=1; do{ printf(μa¶); x++; }while(x<5); x="65535;x">=1;x++) printf("no output"); } 
a . no output 
b . Prints no output infinite times 
c . No output 
d . None of these 

Q. 15 . Find out the output. void main() { int val=2; val = - --val- val-- - --val; printf("%d",val); } 
a . Compile time Error 
b . 3 
c . -1
d . 0 

Q. 16 . Find the output. void main() { int i=65,j=0; for(j;j<4;j++) a="5,c;" b="6;;" c="a+b;" today="{3,7,6,2007};" num="345," sum="0;" m="num%10;" num="num/10;" sum="sum*10+m;" ch="{μa¶,¶b¶,¶c¶,¶" x=" -350u;" y=" -145u;" p="hai" p="¶H¶;" q="¶B¶" str= "lakshya" x="-17">>2; printf ("%d", x); } 
a . -3 
b . 3 
c . -5 
d . 7 

Q. 13 . Find out the output main() { int i=-3,j=2,k=0,m; m=++i&&++j++k; printf("\n %d %d %d %d",i,j,k,m); } 
a . -2 3 0 1 
b . -3 2 0 1 
c . -2 3 1 1 
d . Error 

Q. 14 . Find the correct output void main() { int *p,*q,*r; q=(int *)malloc(sizeof(int)); p=q-1; r=q+1; *p=100; *q=200; *r=300; p++; q++; printf("%d %d",*p,*q); } 
a . 10 20 
b . 20 20 
c . 20 30 
d . 30 30 

Q. 15 . Find the correct output struct byte {
int a:2; int b:1; int c; }; void main() { struct byte d; printf("%d",sizeof(d)); printf("%d",sizeof(d.a)); } 
a . 4 1 
b . 3 1 
c . Error 
d . None of these 

Q. 16 . Find out the output void main() { printf("\/\*\-*\/"); } 
a . Run time Error 
b . \/*-*\/ 
c . /*-*/ 
d . None of these 

Q. 17 . Find the output. void main() { char ch=¶\356¶; printf("%d",ch); } 
a . -18 
b . 18 
c . Error 
d . 51 

Q. 18 . Find the correct output void main() { char *p="CITE"; char *q; q=(char *)malloc(sizeof(p)); while(*p++=*q++); printf("%s",q); } 
a . CITE 
b . ITE 
c . Empty string 
d . None of these 

Q. 19 . During linking the linker adds more information in the
header of the executable file, known as 
a . link parameter 
b . load parameter 
c . program segment prefix 
d . dynamic link library 

Q. 20 . Character constant is 2 byte long to represent 
a . hexadecimal constant 
b . octal constant 
c . both octal & hexadecimal constant 
d . none of these 

Q. 21 . Find the correct output void main() { int x; x=compute(4); printf("%d",x); } int compute(int n) { if(n<=1) return 2; else return(compute(n-2)*compute(n-1)); } 
a . 10 
b . 8 
c . 16 
d . 32 

Q. 22 . Find the correct output #include"string.h" #include"alloc.h" void main() { struct linklist { int item; struct node *link; }; struct linklist *p,*q; p=(struct linklist *)malloc(sizeof(struct linklist)); q=(struct linklist *)malloc(sizeof(struct linklist)); p-> item=10; q-> item=20; p-> link=q; q-> link=p; while(p) { printf("%d",p->item); p=p->link; } } 
a . 101010«««. 
b . 10201020««.. 
c . 202020«««.. 
d . None of these 

Q. 23 . Unary operators are 
a . Operator dependant 
b . Position dependant 
c . Value dependant 
d . Both b and c. 

Q. 24 . Find out the output. void main() {
char c=65; c=(!=c); printf("%d",c); } 
a . 0 
b . 65 
c . 1 
d . 66 

Q. 25 . The secret signature of Borland International (in Turbo C 3.0) is kept in 
a . data area 
b . code area 
c . text area 
d . none of these 

Q. 26 . Stack is useful for implementing 
a . Recursion 
b . Breadth first search 
c . Both a and b 
d . None of these 

Q. 27 . State the true statement. μvoid μ is an empty data type associated with 
a . all aggregate types 
b . all data types 
c . all functions and pointers 
d . all the above 

Q. 28 . Find out the output void main() { char *s[]={"utpal","bubu"}; printf("%c %s",*name[0],name[1]); } a . u bubu 
b . u garbage 
c . garbage bubu 
d . None of these 

Q. 29 . Find the correct output void main() { int i=5; enum vehicle{car=i,bike,scooter}; printf("%d",car); } 
a . 0 
b . 5 
c . Error 
d . None of these 

Q. 30 . A unit of 8 bits is known as byte in same way a unit of
4 bits is known 
a . half byte 
b . ribble 
c . nibble 
d . none of these 

MCQ of c programming 17
Q. 1 . Find out the output void main() { int x,y; *(&x)=10; *(&y)=13; printf("won%cder%c",y,x); } 
a . der 
b . won13der13 
c . won1der1 
d . won der 

Q. 2 . Find the correct output void main() { struct place { char *str; int i; struct place *ptr; }; static struct place a[]={{"Raipur",1,arr+1}, {"Nagpur",2,arr+2}, {"Kanpur",3,arr} }; struct place *p=a; int i; for(i=0;i<=2;i++) { printf("%d",(2+a[i].i)); } } 
a . Error 
b . aipuragpuranpur 
c . ipurgpurnpur 
d . purpurpur 

Q. 3 . Find the correct output void main() { int var,x=1,y=2; switch(var) { case x: x++; case y: y++; } printf("%d %d",x,y); } 
a . 1 3 
b . 2 2 
c . No output 
d . None of these 

Q. 4 . Find the output. void main() { char c[]="lak\\bshya"; printf("%s",c); } 
a . lashya 
b . lak\shya 
c . lak\bshya 
d . lakshya 

Q. 5 . File opening is 
a . a action of connecting a program to a file 
b . a action of connecting a program to a buffer 
c . a default action of file processing 
d . None of these 

Q. 6 . Find out the output. int funcall(); void main() { int z; z=funcall(); printf("%d",z); } int funcall() { auto int arr[]={15,2,3,4,5,6},x=5; return
x=arr[0]; x=arr[1]; printf("%d",x); } 
a . 15 
b . 2 
c . Error 
d . Garbage output 

Q. 7 . Find the output void main() { if(printf("Hello")); else printf("Hai"); } 
a . Hello 
b . Hai 
c . Compilation error 
d . Statement missing 

Q. 8 . The value with in [ ] in an array declaration specifies 
a . Largest permitted subscript value 
b . Size of the array 
c . Both a and b 
d . None of these 

Q. 9 . Find the output. void main() { int x=0xFFFB; printf("%d",x); } 
a . 5 
b . -5 
c . 65631 
d . 32762 

Q. 10 . Find out the output. void main() { int a=1,b=2,c=3,d=4; printf(" %d %d",a,b); printf(" %d %d",c,d); } 
a . Run time Error 
b . Compile time Error 
c . 1 2 3 4 
d . None of these 

Q. 11 . Find out the true statement. 
a . A union variable can be assigned to another union variable. 
b . The address of union variable can be extracted by using & operator. 
c . A function can return a pointer to the union. 
d . All the above 

Q. 12 . Find the correct output void main() { int x=11,y=5,z=2; x%=y*=z; printf("%d",x); } 
a . 2 
b . 1 
c . 25 
d . 27 

Q. 13 . Find the output void main() { int i=-3,j=2,k=0,m; m=++i && j++ && ++k; printf("\n%d, %d, %d, %d",i,j,k,m); } 
a . -2,-3, 1,1 
b . -3, 2, 0,1 
c . -2, 3, 0,1 
d . -2, 3, 1,1 

Q. 14 . Find out the output #include"stdio.h" void main() { int (*p)(const char* , ...); p=printf; p("hello","%c",'CB'); } 
a . helloC 
b . helloCB 
c . hello%c 
d . hello 

Q. 15 . Find the correct output void main() { unsigned i=1; signed j=-1; if(ij) printf("greater"); else if(i==j) printf("equal"); } 
a . less 
b . greater 
c . equal 
d . None of these 

Q. 16 . Find the correct output #define CAL(X) X+1 void main() { int a=3; int b=4*CAL(a*4); printf("%d",b); } 
a . Garbage value 
b . 52 
c . 64 
d . 49 

Q. 17 . Self referential structure 
a . Used to create a memory link.
b . Plays an important role in linked list creation. 
c . Contains the object of same structure which is of pointer type. 
d . All the above 

Q. 18 . Find the correct output void main() { int *p,i=10; void *q; p=&i; q=p; printf("%d",*q++); } 
a . 10 
b . 11 
c . Error 
d . None of these 

Q. 19 . Find the output struct xx { char y; int x; }; void main() { struct xx s={μa¶,15}; switch(s) { case μa¶: printf("Allowed"); break; case 15: printf("Not allowed"); break; default: printf("No"); } } 
a . Allowed 
b . Not allowed 
c . No 
d . None of these 

Q. 20 . Find the output. void main() { int i; for(i=-9;!i;i++);
printf("%d",-i); } 
a . 8 
b . 9 
c . 0 
d . 1 

Q. 21 . Find out the output. void main() { int arr[5]={},i; char *p; for(i=0;i<5;i++) p="(char*)arr;" m="hii(m="1,n="2);" k="!m?n:!n?m:m<="n?m:n;" i="j="l="0;" s="1;">=n))&&(l+=n,s=- s,++j>=m)) break; i-=s; l+=s*m; k=l>0?l1.5) printf("fool"); else printf("stupid"); } 
a . fool 
b . stupid 
c . garbage value 
d . None of these 

Q. 12 . Find the correct output void main() { int i=5,j=3; printf("%d",show(i,j)); } show(int a,int b) { a=a*5; b*=b; return(!a+ --b); } 
a . Error 
b . 0 
c . 8 
d . 2 

Q. 13 . Find out the output #include"limits.h" void main() { int a[INT_MAX];
printf("%d",sizeof(a)); } 
a . 32767 
b . 63534 
c . -2 
d . 2 

Q. 14 . Find the correct output void main() { int a; char b; float c; printf("%d",sizeof(a+sizeof(b+c)); } 
a . 2 
b . 1 
c . 4 
d . Error

Q. 15 . Find out the output int i; int increment( int i ) { i++; return i; } int main() { for( i = 0; i < i="increment(" i="%d\n" i="9" i="10" i="11" p="CITE" q="CITE" p="="q)" a="5,b="7;" p="&a;" p="10;" a="4,b="5,c;">b?c=a:c=b); } 
a . 4 
b . 5 
c . Error, lvalue required 
d . None of these 

Q. 22 . Find the output. void main() { int *p, a[5]={1, 2, 3, 4, 5}; p=&a; printf("%d %d %d",*p,++*p,++*p); } 
a . 1 2 3 
b . 3 2 1 
c . 3 3 2 
d . None of these 

Q. 23 . A union can be a member of
a . Structure 
b . Array 
c . Both a and b 
d . None of these 

Q. 24 . Find the correct statement 
a . int a=10; int arr[a]; 
b . int a,b,c; int *p={&a,&b,&c}; 
c . static int a,b,c; int *q={&a,&b}; 
d . int a=1,b=2,c=3; int arr[]={a,b,c}; 

Q. 25 . Find out the output void main() { int a=10; a=call(a=call(~a)); printf("%d",a); } call(int a) { return a; } 
a . 10 
b . -11 
c . 0 
d . None of these 

Q. 26 . Find the correct output #define FLOAT(x) 3.##x void main() { printf("%f",FLOAT(14)); } 
a . 3.14 
b . 3.140000 
c . 3.000000 
d . None of these 

Q. 27 . State the correct statement. 
a . Nested union is not possible. 
b . Self referential union is possible 
c . Different interpretations for the same memory location are possible in structure. 
d . Both a and c 

Q. 28 . Find out the output void main() {
int a=256; char *p=&a; *++p=2; printf("%d",a); } 
a . 512 
b . 258 
c . Error 
d . None of these 

Q. 29 . Find the correct output void main() { static int i=i++,j=j++; printf("%d%d",i,j); } 
a . 11 
b . Garbage value 
c . Error 
d . None of these 

Q. 30 . The keywords in μr¶ family are 
a . register, real 
b . register, return, repeat 
c . register, return 
d . none of these 

MCQ of c programming 19
Q. 1 . Find out the output void main() { int i,j,a[6],b[3]; j=a[i=0]=1; printf("%d","lakshya"[(sizeof(a[i],"lakshya"[sizeof b[j]]))]); } 
a . 2 
b . 97 
c . 117 
d . 118 

Q. 2 . Find the output. void main() { int x=3; float y=1; while(x! =y) { x--; y++; if(x==y)
printf("%d %d",x,y); } 
a . 2 0 
b . 2 suffering 
c . 2 2 
d . Error 

Q. 3 . An I/O stream is 
a . a text stream 
b . a binary stream 
c . Both a and b 
d . None of these 

Q. 4 . Find the correct output void main() { int i=5; i=i++ - --i + ++i; printf("%d",i); } 
a . 5 
b . 7 
c . 8 
d . None of these 

Q. 5 . Find the output. extern int x; void main() { typedef int myint; myint x; printf ("%d", x) ; } 
a . 0 
b . Garbage 
c . Error, multiple declaration for x 
d . None of these 

Q. 6 . Find the output void main() { int i=1; for(i;i++<=3;) { switch(i) { case 1: printf("one"); continue; case 2: printf("two"); break; case 3: printf("three"); continue; } } } 
a . onetwothree 
b . twothree 
c . Error, misplaced continue 
d . No output 

Q. 7 . Find the correct output? void main() { int n=2,i; float s=0.0; for(i=1;i<=n;i++) s=s+(float)1/(i*i); } 
a . 1.000000 
b . 1 
c . 1.500000 
d . 1.250000 

Q. 8 . Find the o/p struct date { int day,month,year; } void main() { struct date today={3,7,6,2007}; printf("%d %d %d",today.day,today.month,today.year); } 
a . 3 7 6 
b . 7 6 2007
c . Compilation error 
d . None of these 

Q. 9 . Find out the output void main() { char *p="rama"; char *q=0; char *r="\bsita"; strcpy(q,p); strcat(q,r); printf("%s",q); } 
a . ramsita 
b . ramasita 
c . rama\sita 
d . None of these 

Q. 10 . Find out the output void main() { int x=32768; if(2*x) printf("HaHa"); else printf("HoHo"); } 
a . HaHa 
b . HoHo 
c . Expression syntax error 
d . None of these 

Q. 11 . Find the output. void main() { int x=5; void *p; p=&x; printf("%d",*(int *)p); } 
a . 5 
b . Garbage 
c . Generic pointer can not be dereferenced 
d . No output 

Q. 12 . Find out the output int x=5; void modify(int); void main() { printf("%d\t",x); { x=10; modify(x); printf("%d",x); } printf("%d",x); } void modify(x) { x=15; x++; } 
a . 5 10 10 
b . 5 16 16 
c . Expression syntax error 
d . None of these 

Q. 13 . A set of names can be represented as a 
a . Two dimensional array of characters 
b . One dimensional array of strings 
c . One dimensional array of pointers to character 
d . All of the above 

Q. 14 . A character constant is 
a . 1 byte long 
b . 2 bytes long 
c . system dependent 
d . none of these 

Q. 15 . Predict output if value 10 is given as input. main() { int i; printf("%d",scanf("%d",&i)); } 
a . 1 
b . 10 
c . Garbage 
d . None of these 

Q. 16 . Find the output. void main() { int i=10,*p; p=&i; printf ("%d %d",*(p++), (*p)++); } 
a . 11 10 
b . 0 10 
c . 10 11 
d . Garbage garbage 

Q. 17 . Find the output union usa { unsigned int x[2]; char ch[4]; }canada; void main() { strcpy(canada.ch,"xyz"); printf("%s %d",canada.ch,canada.x[1]); } 
a . Error: Library function not allowed initializing union member. 
b . xyz 120 
c . xyz 121 
d . xyz 122 

Q. 18 . Find out the output void main() { char a[10]="lakshya"; int i=0,j=0; while(i<=strlen(a)) { i=j++; if(a[i]==¶a¶a[i]==¶e¶a[i]==¶i¶a[i]==¶o¶a[i]==¶u¶) { while(iy? x:y void main() { int a,b; a=MAX(1,2)+3; b=MAX(4,3)+5; printf("%d %d",a,b); } 
a . 5 4 
b . 5 9 
c . 5 8 
d . None of these 

Q. 20 . Find the output. static int i; void main() { for(;~i;i--)
printf("%d",i); } 
a . 0 -1 -2 -3««. 
b . 0 
c . 0 -1 0 -1«« 
d . None of these 

Q. 21 . Find the correct output void main() { char a[4]="rama"; char b[]="shyama"; printf("%d %d", sizeof(a),sizeof( b)) ; } 
a . 4 7 
b . 5 6 
c . 5 7 
d . 4 6 

Q. 22 . The keywords in μr¶ family are 
a . register, real 
b . register, return, repeat 
c . register, return 
d . none of these 

Q. 23 . Find out the output struct xx { int xx; char yy[10]; }; struct yy { char xx[10]; int yy; }; struct xx *rec; struct yy rect={"hari",20}; void main() { rec=(struct xx*)&rect; printf("%c %s",rec->xx,rec->yy); } 
a . hari 
b . h ri 
c . riha 
d . r ha 

Q. 24 . Find out the output void main() {
char *p; printf("%d %d ",sizeof(*p+++2),sizeof(p+++4)); } 
a . 1 2 
b . 2 2 
c . Error 
d . 1 1 

Q. 25 . Find the correct output void main() { int i; float f=3.14; float compute(float); i=compute(f); printf("%d",i); } float compute(float x) { if(x==3.14) return(0); else return(1); } 
a . Suffering 
b . Garbage 
c . 0 
d . 1 

Q. 26 . Find the correct output void main() { int i,j=6; for(;i=j;j-=2) printf("%d",j); } 
a . Error 
b . Garbage values 
c . 642 
d . 6420 

Q. 27 . Find the output void main() { char a[5]={μc¶,¶i¶,¶t¶,¶e¶, 0}; printf ("%s",a[4]); } 
a . 0 
b . Null 
c . Error
d . None of these 

Q. 28 . Octal numbers are used 
a . in computer hardware 
b . when binary numbers are too long 
c . external to the computer 
d . in preference to 'hex' numbers 

Q. 29 . Find the output. void main() { struct nm; { int roll[5]; char name[10]; }; printf("%d",sizeof(nm)); } 
a . 20 
b . 21 
c . 10 
d . None of these 

Q. 30 . Find the output void main() { int i=4,j=-3; mul(&i,j); printf("%d %d",i,j); } mul(int *a,int b) { a=*a**a; b=b*b; } 
a . 4 3 
b . 4 9 
c . 16 -3 
d . 16 9 

MCQ of c programming 20

Q. 1 . Find out the output void main() { int i=0,c=0; for(i;i<10;i--) emp="{278," p="&emp;">eid II. p.eid III. (*p).eid IV. (*p)->eid 
a . Only I 
b . Only III
c . Both I & III 
d . All of the above 

Q. 4 . Arrange the operators ~,= =, &&, *, ^ in the increasing order of precedence. 
a . = =, ^ , * , && , ~ 
b . && , ^ , = = , * ,~ 
c . * , = = , && , ^ , ~ 
d . && , = = , ^ , * ,~ 

Q. 5 . Which one of the following is/are wrong? int a,b[5],c[3]; I. a=b[2]; II. b[3]=a; III. b[1]=c[2]; IV. c[0]=b[2 
a . only II 
b . II & III 
c . III & IV 
d . only I 

Q. 6 . Find the correct output void main() { int a=1,b=2,c=3,d=4; printf("%d",!a?b?!c:!d:a); } 
a . 1 
b . 2 
c . 3 
d . 4 

Q. 7 . Find the correct output void main() { int a=5,b=6,c=2,d; d=(a++,++b,c++); printf("%d%d%d",d,a,c); } 
a . 263 
b . 252 
c . 162 
d . 253 

Q. 8 . Find the output. void main() { unsigned int i=5; while(i-->=0) printf("%d",i); } 
a . 12345
b . lvalue required 
c . infinite loop 
d . None of these 

Q. 9 . Which of the following function is appropriate to read one character at a time? 
a . fscanf() 
b . fgetc() 
c . read() 
d . fgets() 

Q. 10 . Find the output static int i=5; void main() { int i=10; call(i/5); printf("%d",i); } call(int i) { return i/2; } 
a . 1 
b . 10 
c . 5 
d . None of these 

Q. 11 . Find out the output void main() { char *p; printf("%d %d ",sizeof(*p+++2),sizeof(p+++4)); } 
a . 1 2 
b . 2 2 
c . Error 
d . 1 1 

Q. 12 . Find out the output void main() { show(5); } show(int x) { static int i=1; while(i++<5) x="65536+1;" p="0X0000;" p="10;" arr2d="="*" arr2d ="="" x="55"> are known as 
a . Data access operators 
b . Structure access operators
c . Member access operators 
d . None of these 

Q. 26 . Find the output void main() { FILE *p; printf("%d %d",stderr->fd,_streams[3].fd); } 
a . 2 3 
b . 4 4 
c . 1 2 
d . Error 

Q. 27 . Find the output void main() { printf("%d",wow(5)); } wow(int x) { if(x<=0) return 1; else return (wow(x-1)+x); } 
a . 15 
b . 16 
c . 11 
d . 12 

Q. 28 . Static global variable have 
a . Internal linkage 
b . External linkage 
c . No linkage 
d . None of these 

Q. 29 . Find out the output void main() int c; { int a=5,b=10; c=a+=b-=a; printf("%d %d %d",a,b,c); } 
a . Compile time error 
b . 5 10 5 
c . 10 5 10 
d . 10 10 5 

Q. 30 . Which of the following is/are true for nested if 
I. It can only test for equality. 
II. Conditions may be repeated for number of times. 
III. It can evaluate relational or logical expressions. 
IV. Character constants are automatically converted to integers. 
a . All of the above 
b . I & II 
c . I, II & III 
d . II, III & IV 

MCQ of c programming 21 

Q. 1 . Find the correct output #define SWAP(type,i,j) {type t=i;i=j;j=t;} void main() { int s=5,t=2; SWAP(int,s,t); printf("%d %d",s,t); } 
a . 5 2 
b . 2 5 
c . 5 5 
d . None 

Q. 2 . Find the correct output #define min(x,y) x=(xb) a=a-b; else b=b-a; } printf("%d",a); } 
a . 3 
b . 6 
c . 18 
d . None of these 

Q. 12 . Unary operators are a
 . Operator dependant 
b . Position dependant
6131
c . Value dependant 
d . Both b and c. 

Q. 13 . what is the o/p in turbo compiler? struct stud { int x:18; char *y; f loat z; }s1; void main() { printf("%d",sizeof(s1)); } 
a . 7 
b . 1 
c . 8 
d . Error 

Q. 14 . Find the correct output void main() { int a[]={6,7,8,9},i; compute(a); for(i=3;i>=0;i--) printf("%d",a[i]); } compute(int *p) { int i; for(i=0;i<4;i++) p="*p-1;" ptr =" (int*)(&a+1);" i="1;" x="10,y="5,p,q;" p="x">9; q=p(x=5,y=10); printf("%d %d %d",q,x,y); } 
a . 1 10 5 
b . Error 
c . 1 5 10 
d . 0 10 5 

Q. 23 . State the true statement. μvoid μ is an empty data type associated with 
a . all aggregate types 
b . all data types 
c . all functions and pointers 
d . all the above 

Q. 24 . The area or scope of the variable depends on its 
a . Date type 
b . Storage class 
c . System type
d . None of these 

Q. 25 . Aspect ratio of a monitor is 
a . height and width ratio 
b . number of pixels per inch 
c . diagonal length of monitor 
d . none of these 

Q. 26 . Find the correct output #define div(x) x/x void main() { printf("%d",div(16)*16); } 
a . 1 
b . 16 
c . 256 
d . None of these 

Q. 27 . Find the output if inout is 5 6? void main() { int x,y; scanf("%d",&x); scanf("%c %d",&y); printf("%d %d",x,y); } 
a . 5 6 
b . 5 7 
c . 5 garbage 
d . garbage garbage 

Q. 28 . Find the output void main() { int x[][3]={1,2,3,4, 4,5,6}; int i; for(i=0;i<3;i++) a="5;" a="find(a+="find(a++));"> int i; void increment( int i ) { i++; } int main() { for( i = 0; i < i="%d\n" i="9" i="10" i="11" p="0X0000FFFF;" x="5;" p="&x;" i="98;" a="5,b="6,c="2,d;" d="(a++,++b,c++);" a="10;" p="{&a,&b,&c};" q="{&a,&b};" a="1,b="2,c="3;" x="4;" i="0;i<4;i++)" x="-17">>2; printf ("%d", x);

a . -3 

b . 3 

c . -5 

d . 7 



Q. 18 . Find the correct output void main() { int *p,*q="hello"; *p=*q; printf("%s",p); } 

a . Error, suspicious pointer conversion 

b . he 

c . hello 

d . None of these 



Q. 19 . Find out the output. void main() { int i=98; while(100-i++) printf("%u",i); switch(i) case μe¶: printf("Fool"); } 

a . 98 99 100 
b . 99 100 
c . 99 100 Fool 
d . Expression syntax error 

Q. 20 . Find the output. #include"stdio.h" void main() { FILE *p; char ch; p=fopen("raja.txt","w"); putc(50,p); putc(80,p); putc(70,p); while((ch=getc(p))!=EOF) putch(ch); fclose(p); } 
a . 508070 
b . 2PF 
c . 50PF
d . None of these 

Q. 21 . The main advantage of union over structure is 
a . Memory mapping 
b . Memory utilization 
c . Memory optimization 
d . Memory leak 

Q. 22 . μfor¶ loop can¶t be written using do-while loop if 
a . Start value is not given 
b . Stop value is false 
c . Step value is not given 
d . Stop value is true 

Q. 23 . Which of the following is false regarding bit fields? 
a . Bit fields may share a storage unit with other structure members. 
b . Bit fields must entirely reside in a storage unit its appropriate type. 
c . Bit fields only applicable to unsigned integral but not signed integral. 
d . Bit fields are used to construct the protocol header fields. 

Q. 24 . Macros like INT_MIN, INT_MAX are defined in which header file. 
a . stdio.h 
b . limits.h 
c . dos.h 
d . none of these 

Q. 25 . Find the correct output void main() { int i=5; i=i++ + ++i + i++; printf("%d",i); } 
a . 18 
b . 20 
c . 24 
d . None of these 

Q. 26 . Find the output void main() { printf("%f",9/5); } 
a . 1.0 
b . 1.8 
c . 
2.0 

d . None of these 

Q. 27 . Find the output. void main()
{ struct nm; { int roll[5]; char name[10]; }; printf("%d",sizeof(nm)); } 
a . 20 
b . 21 
c . 10 
d . None of these 

Q. 28 . Which of the following is a 8 bit binary coding? 
a . BCD 
b . ASCII 
c . EBCDIC 
d . none of these 

Q. 29 . Find out the output. void main() { printf("%d",-65535); } 
a . -65535 
b . 0 
c . 1 
d . -1 Q. 

30 . Find out the output void main() { int a="%d"; printf("%d",a); } 
a . %d 
b . 25637 
c . 37 
d . %

* To get Clear; figures / diagrams, tables / values, formulas / formulae, answers / explanations and more, download the Oracle Job Technical Interview Latest Solved Placement Paper PDF.

Like our Facebook


WhatsApp - Group

Message 'ADD ME'
@ +91- 7893356131