2) n=7623
{
temp=n/10;
result=temp*10+ result;
n=n/10
}
a)3267
b)3762
c)7623
d)3627
Ans :a
----------------------------------------------
3) If A>B then
F=F(G);
else B>C then
F=G(G);
in this , for 75% times A>B and 25% times B>C then,is 10000 instructions
are there ,then the ratio of F to G
[a] 7500:2500 [b] 7500:625 [c] 7500:625 if a=b=c else
-------------------------------------------------------------------------------------------------
4) C program code
int zap(int n)
{
if(n<=1)then zap=1;
else zap=zap(n-3)+zap(n-1);
}
then the call zap(6) gives the values of zap
[a] 8 [b] 9 [c] 6 [d] 12 [e] 15
Ans:
---------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
6)What is the output
Int count=10,sum=0,*temp;
Temp=&count;
Sum=∑ &count;( It was actually given temp=∑ &count; which is
probably wrong)
Printf(“sum=%d count= %d temp=%d “,sum,count,*temp);
Ans. C (most expected answer ,check it)
-------------------------------------------------------------------------------------
7) Which one has no L-Value
[i] a[i]
[ii] i
[iii] 2
[iv] *(a+i)
Ans . [iii]
-------------------------------------------------------------------------------------
8) In threaded binary for which traversal orders unused left and right links
are used?
Ans.
--------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
11) main()
{
printf("%c","abcdef"[4]);
}
what is the output ?
a) abcdef
b) d
c) e
d) ERROR.
-------------------------------------------------------------------------------------
12) main()
{
char dummy[20];
scanf("%[^a]",dummy);
printf("%s", dummy);
}
what will it do?
a) ERROR
b) take characters till ctrl z is pressed
c) take upto 19 characters
d) None of These
------------------------------------------------------------------------------------
Ans:a
-----------------------------------------------------------------------------------------
14) Link list is implemented as a structure (data, link *), How is pointer
moved to the next node , cursor points to the present node.
a) cursor = cursor->link
b) cursor ++
c) ++ cursor
d) None of these.
-----------------------------------------------------------------------------------------
15)const char* ptr is:
a.constant character to the pointer
-----------------------------------------------------------------------------------------
Ans:b
---------------------------------------------------------------------------------------
#define MAX 50
int a[MAX], i, j, temp;
for( i=O;i<MAX-l;++i)
if(a{i]>a{i+l])
C)64
------------------------------------------------------
A)ASCII Valueof121
8)1
C)3
-------------------------------------------------------
----------------------------------------------------------------------------------------------------------
23) x=2,y=6,z=6
x=y==z;
printf(%d",x) ?ANS 1
---------------------------------------------------------------------------------------------------------
24) main()
{
char *p;
p=malloc(10);
free(p);
printf("%d",p);
}
ANS compilation error
--------------------------------------------------------------------------------------------------------
25)a=(10,15)
b=10,15
what are the values of a & b in ANSI C
ANS 15,10
-------------------------------------------------------------------------------------------------------
26)main(){
int x=10,y=15,z=16;
x=y==z;
printf("%d",x);
ANS 0
--------------------------------------------------------------------------------------------------------
27)f(n) f(x)
{
if(x
<=0)
return;
else f(x-1)+x;
}
find the value of fn(5)? ANS 15.
---------------------------------------------------------------------------------------------------------
28)struct {
int det;
struct prevoius;
struct new;
}
delete(struct node)
{
node-prev-next=node-next;
node-next-prev=node-prev;
if(node==head)node
}
one element will be given.
ANS::it does not work when rp is the last element in the link
list.
------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
30)main()
{
int var =25,varp;
varp p=10;
fnc(varp);
printf("%d%d",var,varp);
}
ANS::55,55 (check this out)
--------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
33)the declaration of the variable does not result in one of
The following
ANS allocatrion of the storage space for the varable.
-------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
36)a static funct. say s(),in as file f.c can be invoked from
ANS all functs. in f.c after the definitions of s.
---------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
42) What sorting algos have their best and worst case times equal ?
Ans. O(nlogn) for mergesort and heap sort
---------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
44) A sorting algorithm which can prove to be a best time algorithm in one case
and a worst time algorithm in worst case is
(a) Quick Sort
(b) Heap Sort
(c) Merge Sort
(d) Insert Sort
Ans. (a)
--------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------
------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
48) printf("%c","abcdef",4[]);
output of above program:
---------------------------------------------------------------------------------------
49)what happens when an array pointed out by temp is freed using free()?
------------------------------------------------------------------------------------------
50)if a linked list has to act as a stack which operations are to be performed?
ans deletion @front,insertion@front
-----------------------------------------------------------------------------------------
51) Which is an error.
Int *p[3]
Int (*p)[3]
(Int *)(int ,int)
Int (*p[3])
Int *(p[3])
-----------------------------------------------------------------------------------------------------
52) a[5]=={1,2,3,4,5}
printf("%d",a[3]);
printf("%d",3[a]);
printf("%d",*(a+3);
what is the output.
-------------------------------------------------------------------------------------------------
53) if(r==5!==4)
printf("inside");
else
printf("outside");
printf("%d",r);
------------------------------------------------------------------------------------------------
54) for(i==0,j==0;i<10,j<10;i++,j+);
printf("%d",j);
(compilation error,run time error,0)
-----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------
---------------------------------------------------------
------------------------------------------------------------------------------------
Ans. (a)
--------------------------------------------------------------------------------------
59) A sorting algorithm which can prove to be a best time algorithm in one case
and a worst time algorithm in worst case is
Ans. (a)
-------------------------------------------------------------------------------------------
----------------------------------------------------------------
61) What data structures you should use for dictionary searching and it
should be capable of doing spell check also ?
Ans: Hashing
------------------------------------------------------------------
62) main()
{
printf("%c","abcdef"[4]);
}
------------------------------------------------------------------------------------------------------
63) main()
printf("%s", dummy); }
a) ERROR b) take characters till ctrl z is pressed c) take upto 19 characters d) None of
These
---------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------
65) about doubly likn list : to delete a node to the right of p , which of the following is
true?
a.p->right=p->right->right;p->right->right->left=…
b.
c.
--------------------------------------------------------------------------------------------------------
66) the best case & worst case merge sort algorithm (I don’t remember the q properly)
------------------------------------------------------------------------------------------------------
a.sHello
b.s
c.Hello
d.error
D None
-----------------------------------------------------------------------
69) Which of the foll will print the sum of the values from10 - 100
asuming that post is initiaised to 0
a==a+I
B For(int I=;I<=0;I++)
a==a+I
--------------------------------------------------------------------
a a
b *(a+I)
c &a[I]
d None
--------------------------------------------------------------------
--------------------------------------------------------------------
-------------------------------------------------------------------------------------------
-----------------------------------------------------------------
74) What is the output of the program?
int n=f,m;
n==m++;
m==++n;
printf(n, m);
ans(f,f)
-------------------------------------------------------------------------------------
Ans: when we are declaring array has some num[5],that means it has the limit to has the 5 elements...
in this first one we have to answer like "5" the lenght of that array...
so compiler thinks that it is an error and it is raising an exception that Arryindexout of Bound error
-------------------------------------------------------------------
77 ) Operation of queue
A. FIFO
B. LIFO
C. FILO
D. none of these
----------------------------------------------------------------------------------------------------------------------
78) main()
{
printf("%c","abcdef"[4]);
}
what is the output?
A. abcdef
B. d
C. e
D. ERROR
----------------------------------------------------------------
answer is B
----------------------------------------------------------------------
ans -D
reason- character constant must be one or two characters long ........therefore an error will be
reported....
----------------------------------------------------------------------------------------------------------------------------------------.
--------------------------------------------------------------------------
82) Stacks and queues are
-----------------------------------------------------------------------------------------------------
83) The operation to be performed on a stack using a linked list can be
realized using the function
---------------------------------------------------------------------------------------------------------------------------------------
Ans:A
----------------------------------------------------------------------------------------------------
85) Mode of operation of stack ______
A. LIFO
B. FIFO
C. FCFS
D. none of these
Ans:A
-------------------------------------------------------------------------------------------------------
86) What is the output?
int i=7
printf("%dn",i++*i++);
Ans:56
----------------------------------------------------------------------------
87) int lion(int x)
// x is positive int
{
while (x!=10 && x%2==0)
x+=2;
return x;
}
int tiger (int x)
{
do
{
x+=2;}
while (x!=10 && x%2==0);
return x;
}
for which values of x is it true that lion(x) equals tiger(x)
----------------------------------------------------------------------------
88) Which variable can be accessed by all the functions of a program?
global variables
---------------------------------------------------------------------------
89) Which of the following is a nonlinear data structure?
A. stack
B. queue
C. linked list
D. tree Ans:D
------------------------------------------------------------------------------------------------------------------------------------------
deletion @front,insertion@front
------------------------------------------------------------------------------------------------------------------------------------------
compilation error
92) main()
{
int a[2]={4,5};
a[0,1]=45;
printf("%d%d",a[0],a[1]);
}
A. 4 45
B. 4
C. 45
D. None
----------------------------------------------------------------------------------------------------------------------------------------------
93) What is quick sort order and merge sort order? Which is used
mostly?
-----------------------------------------------------------------------------
STACK
------------------------------------------------------------------------------
----------------------------------------------------------------------------
96) main()
{
i=10;
printf("%d",++i++);
printf("%d",++i);
}
A. 11 and 13
B. 12 and 13
C. error
D. Both A and B
Ans:c
-------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------
98) main()
{
int a[]={0 1 2 3};
int *b;
b=&a[2];
printf("%d",b[-1]);
}
--------------------------------------------------------------------------
99) main()
{
char a[2];
*a[0]=7;
*a[1]=5;
printf("%d",&a[1]-a)
ANS:
ans may be 1.(illegal initialization)
--------------------------------------------------------------------------------------------------
100)
#include<stdio.h>
main(){
char a[]="hellow";
char *b="hellow";
char c[5]="hellow";
printf("%s %s %s ",a,b,c);
printf(" ",sizeof(a),sizeof(b),sizeof(c));
}
(ans is hellow,hellow,hellow
6,2,5 )
------------------------------------------------------------------------------------------------
101)
#include<stdio.h>
main()
{
float value=10.00;
printf("%g %0.2g %0.4g %f",value,value,value,value)
}
(ans is 10,10,10,10.000000)
-----------------------------------------------------------------------------------------------
102)
#include<stdio.h>
void function1;
int i-value=100;
main()
{
i-value=50;
function1;
printf("i-value in the function=",i-value);
printf("i-value after the function=",i-value);
}
printf("i-value at the end of main=",i-value);
functioni()
i-value=25;
------------------------------------------------------------------------------------------------
103)
main()
{
funct(int n);
{
switch(n)
case1:
m=2;
break;
case2:
m=5;
break;
case3:
m=7;
break;
default:
m=0;
}
THIS IS ROUGH IDEA:
(ANS:Out put is m=0)
---------------------------------------------------------------------------------------------
104)Give the output of the C program..
main()
{
int i=10,j;
for(j=0;j<1;j++)
{
int i=20;
printf("%d",i);
}
printf("%d",i);
}
a. 10,10
b. 10,20
c. Garbage Value
d. Multiple declaration error
Ans. 10,20
-----------------------------------------------------------------------------------------------------
a. 20
b. 0
c. Error
d. Garbage Value
-----------------------------------------------------------------------------------------------------
main()
{
int n=6;
print("%d",n);
}
----------------------------------------------------------------------------------------------------
107)main()
{
int i;
i=2300*10+20+1900*0;
printf("%d",i);
}
a)0
b)-320000
c)230020
ans c
------------------------------------------------------------------------------------------------
108)main()
{
int arr[5]={2,4};
printf("%d %d %d \n",arr[2],arr[3],arr[4]);
}
-----------------------------------------------------------------------------------------------
109)main()
{
struct e{
char name[20];
int a;
float b;
};
struct e ast={"Hell"};
print("%d %f \n",ast.a,ast.b);
}
------------------------------------------------------------------------------------------------
111) What is the ouput?
Main()
{
Int i=0;
Switch(i)
Case 0 : printf("%d",i);break;
Case 1 : printf("%d",i);break;
}
A) Compiletime error B)0 C)01 D) Runtime error
112) What is the output of the program
Main()
{
int q=2,d=3,st;
st=q*d/412/12+12/3*16/d;
printf("st=%d",st);
}
A) 21 B)21.0 C)21.2 D)None of these
31) what is the output?
Main()
{
int i=0;
switch(i)
{
case 0:
i++;
printf("%d..",i);
case 1:
printf("%d..",i);
case 1:
printf("%d..",i);
}
}
A)..1..1..0 B) 0..1..1 C) 1..1..1 D) None of These
32) What will be the O/P?
Main()
{
struct xyz {
int i;
};
struct xyz *p;
struct xyz a;
p=&a;
p>i=10;
printf("%d",(*p).i);
A) 0 B) 10 C) Garbage Value D) Compile Time Error