1) {
int x=3;
if(x==2);
x=0;
if(x==3)
x++;
else
x+=2;
printf(x)
}
ans
2
2) int x=5,y= -10,b=2,a-=4,z;
z=x++ - --y*b/a;
printf(z);
ans
10
3) # include<stdio.h>
void main()
{
int a = 10,b;
b = a++ + ++a;
printf("%d %d %d %d",b,a++,a,++a);
}
Ans : 22 13 13 13
4) # include<stdio.h>
void main()
{
float a = 2.3;
int b = 3;
a = b / 2 + b * 8 / b - b + a /3;
printf("%f"a);
}
Ans : 6.76
5) lines which gives description of what is written in code(something like
this)...answer is:-- comments
6)
if we manipulate array elements in a functions will those changes be reflected
in actual array in main program... answer is no
7) variables in for loop cannot be refrenced outside the for loop
options true/false
answer is true
8) ek ka answer tha top_down approach
9) char a[20]=" hello world"
length of array
answer is 20...because a[20] will reserve 20 memory locations
10) printf("%d", sizeof(2.0))
answer is 8
11) x= 26,m=11,n=16
12) we can’t have more than one statement in ternary operator
13) welcome will be displayed 5 times
14) What is the Output of the Program ?
main()
{
int a = 10 , b = 100 ;
swap(&a , &b) ;
printf("%d %d",a,b) ;
}
swap(int *a , int *b)
{
*a = *a + *b ;
*b = *a - *b ;
*a = *a - *b ;
swap1(&a , &b) ;
}
swap1(int **a , int **b)
{
**a = **a + **b ;
**b = **a - **b ;
**a = **a - **b ;
}
a. 100 10
b. 10 100 (1)
c lvalue is required in fun main
d. error !!
Ans (b)
15) What is the output of the following snippet?
main()
{
int k=1;
printf("%d==1 is ""%s",k,k==1?"TRUE":"FALSE");
}
a. 1==1 is TRUE
b. 1==49 is TRUE
c. 1==1 is FALSE
d. 1==49 is FALSE
Feedback
a)Correct-because == has higher precedence than ?:
b)Incorrect- because == has higher precedence than ?:
b)Incorrect- because == has higher precedence than ?:
b)Incorrect- because == has higher precedence than ?:
16) What is the output of the following?
main()
int i=-1,j=-1,k=0,l=2,m;
m=i++&&j++&&k++||l++;
printf("%d %d %d %d %d",i,j,k,l,m);
}
a. 1,1,1,1,1
b. 2,1,2,3,1
c. 0,0,1,3,1
d. None of the above
Feedback:
A.) Incorrect-According to operator precedence, incrementor operator has higher precedence
than logical operators.
B.) Incorrect- According to operator precedence, incrementor operator has higher precedence
than logical operators.
C.) Correct - According to operator precedence, incrementor operator has higher precedence
than logical operators.
D.) Incorrect- According to operator precedence, incrementor operator has higher precedence
than logical operators.
17) main()
{
int j=1;
while(j<=255);
{
printf(%c %d\n”,j, );
j++;
}
}
a. 1…255
b. 11
c. Infinite loop
d. None of the above
Feedback:
A.) Incorrect- The program goes into a infinite loop. this occurs because of the semi-
colon after the while statement. It is a loop without any updation statements. so it
does not come out of the loop.
B.) Incorrect-. The program goes into an infinite loop. This occurs because of the semi-
colon after the while statement. It is a loop without any updation statements. So it
does not come out of the loop.
C.) Correct: The program goes into an infinite loop. This occurs because of the semi-
colon after the while statement. It is a loop without any updation statements. So it
does not come out of the loop.
Incorrect - The program goes into an infinite loop. This occurs because of the semi-
colon after the while statement. It is a loop without any updation statements. So it does
not come out of the loop.
18) When you pass an array as an argument to a function , what actually gets
passed?
a) Address of the array
b) Values of the elements of the array
c) Address of the first element of the array
d) Address of the first element of the array
Feedback
A.) Incorrect-Array name indicates base address i.e. address of first element of the
array.
B.) Incorrect- Array name indicates base address i.e. address of first element of the
array.
C.) Correct- Array name indicates base address i.e. address of first element of the
array.
D.) Incorrect- Array name indicates base address i.e. address of first element of the
array.
19) What is the output of the following program
main()
{
char s[ ]="man";
int i;
for(i=0;s[ i ];i++)
printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);
}
a. m a n
b. no output
c. mmmm
aaaa
nnnn.
d. None of the above
Feedback
A.) Incorrect-all the characters of string s are printed 4 times since all the arguments in
the printf statement are equivalent forms
B.) Incorrect- all the characters of string s are printed 4 times since all the arguments in
the printf statement are equivalent forms
C.) Correct-.-all the characters of string s are printed 4 times since all the arguments in
the printf statement are equivalent forms
D.) Incorrect--all the characters of string s are printed 4 times since all the arguments in
the printf statement are equivalent forms
20) main()
int *i, *j;
*i=10;
*j=20;
abc (&I, &j);
printf(“%d”, *i);
abc(int *i, int *y)
*i=*i**i;
*j=*j**j;
What will be the value of i?
a) 101
b) 20
c) 100
d) 10
20) main()
int a;
printf(“%d”, scanf(“%d”, &a)); /*Input given is 420*/
a) 2
b) 10
c) 1 (Ans)
d) 420
21) main()
int i=35, j=45;
j=i,j?(i,j)?i:j:j;
printf(“%d%d”, i,j);
a) 35 45
b) 45 45
c) 35 35 (Ans)
d) None
22) main( )
int a[2][2];
int i,j;
for(i=1;i<=2; i++)
for(j=1;j<=2;j++)
if(j==1)
a[i][j]=1;
else
a[i][j]=0;
printf(“%d”, a[i][j]);
}
What will be the output:
a) 0000
b) 1111
c) 1010
d) 1001
23) Does structure is allocated a continuous memory?
Ans: True
24) main( )
struct imp
char c[];
char *b;
};
struct dept
char *d;
struct imp e;
};
struct dept ={“HR”,”Accts”,”Sales”}
printf(“ %s %s”, c.e, d.e);
a) error
b) HR
c) HR Sales (Ans)
d) Accts Sales
25) A field-width specifier in a printf( ) function:
1. Controls the margins of the program listing
2. Specifies the maximum value of a number
3. Controls the size of font used to print numbers
4. Specifies how many columns would be used to print the number (Ans)
26) How to retrieve the address of first memory allocation of an array:
a) arr (Ans)
b) &arr (Ans)
c) arr[0]
d) arr[1]
27) Which of the following are correct variable name:
a) int abc_123; (Ans)
b) int abc_$#
c) int 123_ab
d) int 2abc
28) To receive the string “We got the guts, you get the glory!!” in an array char
str[100] which of the following functions would you use?
1. scanf ( “%s”, str );
2. gets( str );
3. getche( str );
4. fgetcahr( str );
29) If a file contains the line “I am a boy\r\n” then on reading this line into the
array str[ ] using fgets( ) what would str[ ] contains?
1. I am a boy\r\n\0
2. I am a boy\r\0
3. I am a boy\n\0
4. I am a boy
30) What would be the output of the following program?
main( )
int a=250
printf ( ‘%1d”, a);
1. 250
2. 251
3. 249
31) An expression contains relational operators, assignment operators, and
arithmetic operators. In the absence of parentheses, they will be evaluated in which
of the following order:
1. assignment, relational, arithmetic
2. arithmetic, relational, assignment
3. relational, arithmetic, assignment
4. assignment, arithmetic, relational,
32) The break statement is used to exit from:
1. an if statement
2. a for loop
3. a program
4. the main( ) function
33) A do-while loop is useful when we want that the statements within the loop
must be executed
1. Only Once
2. At least Once
3. More than Once
4. None of the above
34) In what sequence the initialization, testing and execution of body is done in a
do-while loop
1. Initialization, execution of body, testing
2. Execution of body, Initialization, testing
3. Initialization, testing, execution of body
4. None of the above
35) Which of the following is not an infinite loop.
. int i=1; 2. for (; ; );
while (1)
{
i++;
}
3. int true=0, false; 4. int y, x=0;
while (true) do
{ {
false = 1; y = x;
} } while (x = = 0);
36) Point out the error, if any, in the for loop.
main( )
int i = 1;
for (;;)
printf( “%d”, i++);
if (i > 10)
break ;
1. The condition in the for loop is a must.
2. The two semicolons should be dropped.
3. The for loop should be replaced by a while loop.
4. No error.
37) What would be the output of the following program?
main( )
char str[]=”Part-time musician are semiconductors’;
int a = 5;
printf(a > 10 ? “%50s” : “%s”, str);
Ans: Part- time musician are semiconductors
Q.38 The variables commonly used in C functions are available to all functions in a program.
(True/False)
Q.39 To return the control back to the calling function we must use the keyword return.
(True/False)
Q.40 The same variables names can used in different functions, without any conflict.
(True/False)
Q.41 Every called function must contain a return statement. (True/False)
Q.42 A function may contain more than one return statement. (True/False)
Q.43 A function may be called more than once from any other function. (True/False)
Q.44 It is necessary for a function to return some value. (True/False)
Q.45 In C all functions except main( ) can be called recursively. (True/False)
Q.46 Usually recursion works slower than loops. (True/False)
Q.47 How many times the following program would print ‘Jamboree’?
main( )
printf( “\nJamboree”);
main( );
1. Infinite number of times
2. 32767 times
3. 65535 times
4. Till the stack doesn’t overflow
Q.48 What would be the output of the following program?
char* myFunc (char *ptr)
ptr += 3;
return (ptr);
int main()
char *x, *y;
x = "HELLO";
y = myFunc (x);
printf ("y = %s \n", y);
return 0;
What will print when the sample code above is executed?
1. y = HELLO
2. y = ELLO
3. y = LLO
4. y = LO
Q.48 What would be the output of the following program?
int a=10,b;
b=a++ + ++a;
printf("%d,%d,%d,%d",b,a++,a,++a);
what will be the output when following code is executed
1. 12,10,11,13
2. 22,10,11,13
3. 22,11,11,11
4. 22,13,13,13
49) in bottem up approach we do
1.start from the most basic subroutine first and ……………..
2.reusability of code
Two options were correct.