Anda di halaman 1dari 24

1) Return address will be returned by function to

[a] Pushes to the stack by call


Ans :
------------------------------------------

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:

---------------------------------------------------------------------------------------------------

5) What is the output of the following code snippet


main()
{
printf(5+”Fascimile”);
}
a)scimile b)mile c)Fascimile d)none
Ans. b

-----------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------------

9) Which is false for binary tree?


[i] Any node should have two children.
[ii]
[iii] At fourth level the number of node should be less than 16.
Ans.

-------------------------------------------------------------------------------------

10) Which is true for binary search ?


[i] Traversal scheme
[ii]
[iii]Greedy algorithm
[iv] Divide and conquer algorithm
Ans. [iv]
-------------------------------------------------------------------------------------

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
------------------------------------------------------------------------------------

13) If Link list is used to implement a stack what operations should be


implemented :
a) insert front, delete front
b) insert front , delete rear
c) insert rear, delete front
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

-----------------------------------------------------------------------------------------

16) queues principle is:


a)LIFO
b) FIFO
c)FILO
d)None of these

Ans:b

---------------------------------------------------------------------------------------

17) What do "Ivalue" and "rvalue" mean?


A)An '.rvalue" denotes an object that has a location; an
.'lvalue"
is any expression that has a value.
B)An .'Ivalue" denotes an object that has a location; an
"rvalue"
is any expression that has a value.
C)Both are same and can be used interchangeably
D)None of these

18). What is the effect of the following program segment?

#define MAX 50
int a[MAX], i, j, temp;
for( i=O;i<MAX-l;++i)

if(a{i]>a{i+l])

temp = a[i]; a[i]=a[i+l]; a[i + 1] =temp }

A)Arrange the elements ofarray a in ascending order.


B)Counts the number of elements of a greater than its first
element.
C)Reverses t~ numbers stored in the array.
D)Puts the largest value in the last array position.
------------------------------------------------

19). What will be the output of the following code?


inti=7. ,
printf("%d\n", i++ * i++);
A)49 8)56

C)64

------------------------------------------------------

20)What is the o/p of this program


#include<stdio.h>
int main()
{

char value = '\123';


printf("0/oC \n", value);
return 0;
}

A)ASCII Valueof121

8)1

C)3

-------------------------------------------------------

21)What is the other name for Balanced Tree' A)A VL Tree


B)B- Tree
C)Binary Tree
What are Stacks and Queues' A)Primitive data structure
B)Non-primitive data structure
C)Non-linear data structure
D)Spanning Tree
D)Data types

----------------------------------------------------------------------------------------------------------

22) long int size


a) 4 bytes b) 2 bytes c) compiler dependent d) 8 bytes
ans: compiler dependent
----------------------------------------------------------------------------------------------------------

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.

------------------------------------------------------------------------------------------------

29)A code will be given which searches a particular char in


The string.
ANS:: it always works.

---------------------------------------------------------------------------------------------

30)main()
{
int var =25,varp;
varp p=10;
fnc(varp);
printf("%d%d",var,varp);
}
ANS::55,55 (check this out)

--------------------------------------------------------------------------------------------

31)#define VALUE 1+2


main()
{
printf("%d and %d\n",VALUE/VALUE,VALUE*3);
}
ANS:: 5,7

32) which of the following is not basic data type


ANS char*

-----------------------------------------------------------------------------------------------------------
33)the declaration of the variable does not result in one of
The following
ANS allocatrion of the storage space for the varable.

-------------------------------------------------------------------------------------------

34)in C parameters are passed by


ANS:: value only.

-----------------------------------------------------------------------------------------

35)2 variables cannot have the same name if they are


ANS:: in the same block.

--------------------------------------------------------------------------------------

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.

---------------------------------------------------------------------------------------

37)macros and functions do not differ in the following aspects


ANS::variable no of arguments.

---------------------------------------------------------------------------------------

38)one q's in which he will give some different forms of


STRCPY function you will have to find out which form is correct.

--------------------------------------------------------------------------------------

39) Convert the infix to postfix for A-(B+C)*(D/E)


Ans. ABC+DE/*-

--------------------------------------------------------------------------------------

40) What is swapping

------------------------------------------------------------------------------------

41) Assignment operator targets to


Ans. l-value

-------------------------------------------------------------------------------------

42) What sorting algos have their best and worst case times equal ?
Ans. O(nlogn) for mergesort and heap sort

---------------------------------------------------------------------------------------

43) The format specifier "-%d" is used for which purpose in C


(a) Left justifying a string
(b) Right justifying a string
(c) Removing a string from the console
(d) Used for the scope specification of a char[] variable
Ans. (a)

----------------------------------------------------------------------------------------

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)

--------------------------------------------------------------------------------------

45) void main()


{
char *p=??s?Hello?; printf(?%s?,p); }
what is the o/p?
a.sHello
b.s
c.Hello
d.error

-------------------------------------------------------------------------------------

46) Binary search order is n log n(base 2)

------------------------------------------------------------------------------------

47) Which of the following is a non linear data structure?


a. stack b. queue c. linked list d. tree
ans(d)

--------------------------------------------------------------------------------------

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)

-----------------------------------------------------------------------------------------

55) #define prod((a>b)?a*a:b*b)


int p==0,q==-1;
prod(p++,q++)
what is result.

----------------------------------------------------------------------------------------------------------

56) 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);

---------------------------------------------------------

57)Which is false for binary tree?


[i] Any node should have two children.
[ii]
[iii] At fourth level the number of node should
be less than 16.
Ans.

------------------------------------------------------------------------------------

58) The format specifier "-%d" is used for which purpose in C

(a) Left justifying a string


(b) Right justifying a string
(c) Removing a string from the console
(d) Used for the scope specification of a char[] variable

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

(a) Quick Sort


(b) Heap Sort
(c) Merge Sort
(d) Insert Sort

Ans. (a)

-------------------------------------------------------------------------------------------

60) 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: b

----------------------------------------------------------------

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]);
}

what is the output ? a) abcdef b) d c) e d) ERROR.

------------------------------------------------------------------------------------------------------

63) 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

---------------------------------------------------------------------------------------------------

64) 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) euqals tiger(x)
( for all even integers less than 10)

-----------------------------------------------------------------------------------------------

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.O(n),O(logn)..(some ans os this sort were given)

------------------------------------------------------------------------------------------------------

67) void main()


{
char *p=””s”Hello”;
printf(“%s”,p);
}
what is the o/p?

a.sHello

b.s

c.Hello

d.error

68) which of the foll is correct

A static enum num{ON,OFF}

B static const enum num{ON, OFF}

C const enum num{ON, OFF}

D None
-----------------------------------------------------------------------

69) Which of the foll will print the sum of the values from10 - 100
asuming that post is initiaised to 0

A For(int I=;post ==0;I<=0;I++)

a==a+I

B For(int I=;I<=0;I++)

a==a+I

and two more choices

--------------------------------------------------------------------

70) which of the following is not gives an l value

a a

b *(a+I)

c &a[I]

d None

--------------------------------------------------------------------

71)Register variables can hold


a Garbage values
b Arrays
c Double values
d All of the above

--------------------------------------------------------------------

72) When an array is passed to a function what exactly is passed.


a. the values of the array
b. the address of the starting variable in the array.
c. The addresses of the elements in the array
d. None

-------------------------------------------------------------------------------------------

73) What will be the Output


void main()
{
clrscr();
printf("yogesh""bansal");
}

-----------------------------------------------------------------
74) What is the output of the program?
int n=f,m;
n==m++;
m==++n;
printf(n, m);
ans(f,f)

-------------------------------------------------------------------------------------

75) int num[5];


num[5]= ;
The 5 in the first and the second statements denotes

Ans: when we are declaring array has some num[5],that means it has the limit to has the 5 elements...

those are num[0],num[1],num[2],num[3],num[4] that's it

in this first one we have to answer like "5" the lenght of that array...

come to second one num[5] in not a region of that array............

so compiler thinks that it is an error and it is raising an exception that Arryindexout of Bound error

-------------------------------------------------------------------

76) What is the output of the program?


int *p, i==4;
p==&I
(*p)++
printf("%d",p);
-----------------------------------------------------------------

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

----------------------------------------------------------------

79) When an array is passed to a function what exactly is passed.

A. The values of the array


B. The address of the starting variable in the array.
C. The addresses of the elements in the array
D. None

answer is B

----------------------------------------------------------------------

80) What is the output of the program?


main()
{
char a='123'
printf ("%c n",a);
return 0;
}

A. ASCII value of 121


B. 1
C. 3
D. none of these

ans -D

reason- character constant must be one or two characters long ........therefore an error will be
reported....

----------------------------------------------------------------------------------------------------------------------------------------.

81) In queue where do you insert a data?


A. front
B. rear
C. middle

--------------------------------------------------------------------------
82) Stacks and queues are

A. primitive data structures


B. non-primitive data structures
C. non-linear data structures....
D. data types
Ans:B

-----------------------------------------------------------------------------------------------------
83) The operation to be performed on a stack using a linked list can be
realized using the function

A. delete front, insert rear


B. insert front, delete rear
C. delete front, insert front
D. delete rear, insert rear

---------------------------------------------------------------------------------------------------------------------------------------

84) Tree is a type of data structure

A. primitive data structure


B. non-primitive data structure
C. none of these

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

------------------------------------------------------------------------------------------------------------------------------------------

90) If a linked list has to act as a stack which operations are to be


performed?

deletion @front,insertion@front

------------------------------------------------------------------------------------------------------------------------------------------

91) What is the output of the following code?


main()
{
char str[20];
printf("Enter a string: ");
scanf("%[^a]",str);
printf("%[^a]",str);
}

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?

-----------------------------------------------------------------------------

94) What is data structure we use in conversion of postfix to infix?

STACK

------------------------------------------------------------------------------

95) What is the output of the following code?


int main ()
{
int i = -1 ; j = 1 , k = 0 , m ;
m = i++ || j++ && k++ ;
printf ("nn%d %d %d " , i , j , k , m ) ;
}

----------------------------------------------------------------------------

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

-------------------------------------------------------------------------------------------------------

97) What does the function return?


int fun()
{
i=3;
i=6;
if(i=6)
i=7;
return i;
}

----------------------------------------------------------------------------

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;

THIS IS ROUGH IDEA OF THE PROGRAM


ANS ARE
1)i-value in the function=25;
2)i-value after the function=50;
3)i-value at the end of the main=100;

------------------------------------------------------------------------------------------------
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

-----------------------------------------------------------------------------------------------------

105)Give the output of the C program..


main()
{
int i;
printf("%d",i);
}
extern int i=20;

a. 20
b. 0
c. Error
d. Garbage Value

Ans. Garbage Value

-----------------------------------------------------------------------------------------------------

106) Identify error

main()
{
int n=6;
print("%d",n);
}

ans -no error

----------------------------------------------------------------------------------------------------

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);
}
------------------------------------------------------------------------------------------------

110) The output of the program is


Main()
{
Int i=3,a=4,n;
Float t=4.2;
N=a*a/i+i/2*t+2+t;
Printf("%d",n);
}
A)15 B)15.4 C)15.0 D)None of these
--------------------------------------------------------------------------------------------------------------------

111) What is the ouput?
       Main()
      {
         Int i=0;
          Switch(i)
           Case 0 : printf("%d",i);break;
            Case 1 : printf("%d",i);break;
       }

A) Compile­time error    B)0      C)01         D) Run­time error

­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­ 

112) What is the output of the program
      Main()
        {
          int q=2,d=3,st;
           st=q*d/4­12/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

Anda mungkin juga menyukai