120
1. What is the output of the program given below #include<stdio.h> main() { char i=0; for(;i>=0;i++) ; printf("%d\n",i); } 2. What is the output of the following program #include<stdio.h> main() { int i=0; fork(); printf("%d",i++); fork(); printf("%d",i++); fork(); wait(); } 3. What is the memory allocated by the following definition ? int (*x)[10]; 4. What is the memory allocated by the following definition ? int (*x)(); 5. In the following program segment #include<stdio.h> main() { int a=2; int b=9; int c=1; while(b) { if(odd(b)) c=c*a;

C_C++

Embed Size (px)

Citation preview

Page 1: C_C++

1. What is the output of the program given below

#include<stdio.h>main(){char i=0;for(;i>=0;i++) ;printf("%d\n",i);}

2. What is the output of the following program

#include<stdio.h>main(){int i=0;fork();printf("%d",i++);fork();printf("%d",i++);fork();wait();}

3. What is the memory allocated by the following definition ?int (*x)[10];

4. What is the memory allocated by the following definition ?int (*x)();

5. In the following program segment

#include<stdio.h>main(){int a=2;int b=9;int c=1;while(b){if(odd(b))c=c*a;a=a*a;b=b/2;}printf("%d\n",c);}How many times is c=c*a calculated?6. In the program segment in question 5 what is the value of a at the end of the while loop?

Page 2: C_C++

7. What is the output for the program given below

typedef enum grade{GOOD,BAD,WORST,}BAD;main(){BAD g1;g1=1; printf("%d",g1);}

8. Give the output for the following program.

#define STYLE1 charmain(){typedef char STYLE2;STYLE1 x;STYLE2 y;clrscr();x=255;y=255;printf("%d %d\n",x,y);}

9. Give the output for the following program segment.

#ifdef TRUEint I=0;#endif

main(){int j=0;printf("%d %d\n",i,j);}

Page 3: C_C++

10. In the following program

#include<stdio.h>main(){char *pDestn,*pSource="I Love You Daddy";pDestn=malloc(strlen(pSource));strcpy(pDestn,pSource);printf("%s",pDestn);free(pDestn);}

(a)Free() fails(b)Strcpy() fails(c)prints I love You Daddy(d)error

11. What is the output for the following program

#include<stdio.h>main(){char a[5][5],flag;a[0][0]='A';flag=((a==*a)&&(*a==a[0]));printf("%d\n",flag);}Q. What is swapping

Predict the output or error(s) for the following:

1.void main(){

int const * p=5;printf("%d",++(*p));

}a .compiler error b.5 c.6 d.none

2.main(){

float me = 1.1;double you = 1.1;if(me==you)

printf("sita");else printf("geetha");

}a.sita b.geetha c.error d.none

3. main(){

Page 4: C_C++

static int var = 5;printf("%d ",var--);if(var)main();}

a.5 4 3 2 1 b.4 3 2 1 c. 4 d.none4. main(){

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

} a.compiler error b.runtime error c.linker error d.20

5. main(){

char *p;printf("%d %d ",sizeof(*p),sizeof(p));

}a.1 2 b.2 1 c.1 1 d.2 2

6. main(){

int i=3;switch(i) { default:printf("zero"); case 1: printf("one");

break; case 2:printf("two");

break; case 3: printf("three");

break; }

}a.1 b.2 c.3 d.0

7. main(){

int c= --2;printf("c=%d",c);

}a.2 b.1 c.error d. n

8.main(){printf("%p",main);}

Page 5: C_C++

a. b. c. d.

9. main(){ int i=400,j=300; printf("%d..%d");}

a.400 300 b. 300 400 c. 400..300 d.none

10. void main(){

int i=5;printf("%d",i+++++i);

}a.linker error b.compiler error c.6 d.10

11. #include<stdio.h>main(){int i=1,j=2;switch(i) { case 1: printf("GOOD");

break; case j: printf("BAD"); break; }}

a. GOOD b. BAD c.compiler error d.linker error

12. main(){int i=-1;+i;printf("i = %d, +i = %d \n",i,+i);}a. –1,1 b. –1,0 c. –1,-1 d.1,-1

13. main(){main();}a. runtime error b. stack overflow c.both a&b d.none

14. main(){int i=-1;-i;printf("i = %d, -i = %d \n",i,-i);

}

Page 6: C_C++

a. –1,-1 b.-1,1 c.1,-1 d.-1,0

15. main(){ int i=5,j=6,z; printf("%d",i+++j); }a.12 b.11 c. error d.none

16. main(){ int i =0;j=0; if(i && j++) printf("%d..%d",i++,j);

printf("%d..%d,i,j);}

a.1 0 b.0 0 c.0..0 d.none

17. main(){

char *p;p="%d\n";p++;

p++; printf(p-2,300);}

18. void main(){

char a[]="12345\0";int i=strlen(a);printf("here in 3 %d\n",++i);

}

Page 7: C_C++

19. void main(){void *v;int integer=2;int *i=&integer;v=i;printf("%d",(int*)*v);}

20. void main(){int i=i++,j=j++,k=k++;printf(“%d%d%d”,i,j,k);}

21. void main(){static int i=i++, j=j++, k=k++;printf(“i = %d j = %d k = %d”, i, j, k);}

22. main(){unsigned int i=65000;while(i++!=0);printf("%d",i);}

23. main(){

int i=0;while(+(+i--)!=0)i-=i++;printf("%d",i);

}a b c d.

24. main() { signed char i=0; for(;i>=0;i++) ; printf("%d\n",i); }

a. 128 b.127 c. -128 d.0

25. main() {

Page 8: C_C++

unsigned char i=0; for(;i>=0;i++) ; printf("%d\n",i); }

a. 128 b.127 c.infinite loop d.none

26. main(){int i=5;printf(“%d”,i=++i ==6);}

a. 5 b. 6 c. 1 d.

27. Is the following code legal?struct a {

int x; struct a *b; }

a. yes b.no c.cant say d.none

28. What does the following statement mean? int (*a)[4] (a)'a' is a pointer to an array of 4 integers (b)'a' is an array of pointers to integer (c)'a' is a pointer to function returning an integer (d).none29)what is the difference between 123 and 0123 in c? (a)120 (b)40 (c)0 (d)...30. The use of qualifier signed on integers is ..? (a)Compulsory (b)Optional (c)Not required (d)None of these31. if (m%5 == 0 && n%5 == 0) is same as... (a)if (!(m%5) && !(n%5))(b)if (!(m%5 != 0) && !(n%5 != 0))(c)if ((m%5 == 0) && (n%5 == m%5))(d)All of the above  (e)None of these

10.What is the output of the following program ? 1 Let S=0 2 Let I= 5 3 Let J=1 4 Let X=5 5 Let S=S*J 6 Let I=I+1 7 Let J=J*S 8 If I<=5 then goto 4 9 Print S 10 End a. 0 b. 8 c. 12 d. 16 e. None

Page 9: C_C++

11. Algorithm problem  Let R=2; Let R=R+2; Let  K=K+1; Let  K=K*R; Printf  K Let  J= J+K; If  R <= 8 Goto step 2; End.

Which of the fallowing output is not true?  a. 4      b. 36    etc

22. Progaming - program to find how many 1's are present in an integer variable using bitwise operators. Something about dynamic allocation, static functions, macros

23. C++ virtual functions

24. What is an inode in unix?

25. Small program in pascal to add a node to a linked list. (You have to tell what the program does)

26. C strcmp program (You have to tell what the program does)

27. Set of dos commands testing basic familiarity with dir, ren *.t?T, cd etc.

28. What is the order of binary search?

29. What is the order of strassens matrix multiplication?

30. You have to maintain the sorted order of integers and insert ntegers . Which data structure would you use? (tree, list, queue,array?)

31. There are two lists of integers to be merged. Which method would you not use?

32. N an online database system when is data written to disk? (onpressing enter, when commit or update is encountered, at end of data,all of the above)

33. Small prolog function which prints 2345true. You need to tell output.

34. Lisp program given. What does it do? (gcd, lcm, multiplies mxn?)

35. What is paging?

36. What is segmentation?

Page 10: C_C++

8. ex:define max 10main(){int a,b;int *p,*q;a=10;b=19;p=&(a+b);q=&max;}

Q a)error in p=&(a+b) b)error in p=&max c)error in both d) no error

1. find(int x,int y){ return ((x<y)?0x-y)):}call find(a,find(a,b)) use to find(a) maximum of a,b(b) minimum of a,b(c) positive difference of a,b(d) sum of a,b

2. integer needs 2bytes , maximum value of an unsigned integer is(a) { 2 power 16 } -1(b) {2 power 15}-1(c) {2 power16}(d) {2 power 15}

3.y is of integer type then expression3*(y- /9 and (y-/9*3 yields same value if(a)must yields same value(b)must yields different value(c)may or may not yields same value(d) none of the above

4. 5-2-3*5-2 will give 18 if(a)- is left associative,* has precedence over -(b) - is right associative,* has precedence over -(c) - is right associative,- has precedence over *(d)- is left associative,- has precedence over *

5. printf("%f", 9/5);prints(a) 1.8, (b) 1.0, (c) 2.0, (d) none

6. if (a=7)printf(" a is 7 ");elseprintf("a is not 7");prints(a) a is 7, (b) a is not 7, (c) nothing, (d) garbage.

Page 11: C_C++

7. if (a>b)if(b>c)s1;else s2;s2 will be executed if(a) a<= b, (b) b>c, (c) b<=c and a<=b, (d) a>b and b<=c.

8. main(){inc(); ,inc(); , inc();}inc(){ static int x;printf("%d", ++x);}prints(a) 012, (b) 123,(c) 3 consecutive unprectiable numbers (d) 111.

9.preprocessing is done

(a) either before or at begining of compilation process(b) after compilation before execution(c) after loading(d) none of the above.

10. printf("%d", sizeof(""));prints(a) error (b)0 (c) garbage (d) 1.

11.main(){int a=5,b=2;printf("%d", a+++b);}

(a) results in syntax, (b) print 7, (c) print 8, (d) none,

12. process by which one bit patten in to another by bit wise operation is(a) masking, (b) pruning, (c) biting, (d) chopping,

13.value of automatic variable that is declared but not initialized will be(a) 0, (b) -1, (c) unpredictable, (d) none,

14. int v=3, *pv=&v;printf(" %d %d ", v,*pv);output will be(a) error (b) 3 address of v, (c) 3 3 (d) none.

15. declaration enum cities{bethlehem,jericho,nazareth=1,jerusalem}

Page 12: C_C++

assian value 1 to(a) bethlehem (b) nazareth(c)bethlehem & Nazareth (d)jericho & nazareth

16. #include<conion.h>#include<stdio.h>void main(){char buffer[82]={80};char *result;printf( "input line of text, followed by carriage return :\n");result = cgets(buffer);printf("text=%s\n",result);}

(a) printf("length=%d",buffer[1]);(b) printf("length=%d",buffer[0]);(c) printf("length=%d",buffer[81]);(d) printf("length=%d",buffer[2]);

17. consider scanf and sscanf function , which is true(a) no standard function called sscanf(b) sscanf(s,...) is equivalent to scanf(...) except thatinput charecter are taken from string s.(c) sscanf is equivalent to scanf.(d) none of above.

18. #include <stdio.h>main(){char line[80];scanf("%[^\n]",line);printf("%s",line);}what scanf do ?(a) compilation error . illegal format string.(b) terminates reading input into variable line.(c) and (d) other two options.

20 . ceil(-2.) ?(a) 0 (b) -3.0 (c) -2.0 (d) 2

21. for( p=head; p!=null; p= p -> next)free(p);(a) program run smooth. (b) compilation error.(c) run time error. (d) none of above.

22. int x[3][4] ={{1,2,3},{4,5,6},

Page 13: C_C++

{7,8,9}}(a) x[2][1] = x[2][2] =x[2][3] = 0(b) value in fourth column is zero(c) value in last row is zero(d) none of above.

24. main (){printf("%u" , main());}(a) print garbage.(b) execution error(c) printing of starting address of function main.(d) infinite loop.

25 . int a, *b = &a, **c =&b;.............a=4;** c= 5;

(a) doesnot change value of a(b) assign address of c to a.(c) assign value of b to a. (d) assign 5 to a.

30 . i =5;i= (++i)/(i++);printf( "%d" , i);prints ,(a) 2 (b) 5 (c) 1 (d) 6

Page 14: C_C++

1. What is the output of the program given below#include<stdio.h>main(){char i=0;for(;i>=0;i++) ;printf("%d\n",i);}

2. What is the output of the following program#include<stdio.h>main(){int i=0;fork();printf("%d",i++);fork();printf("%d",i++);fork();wait();}

3. What is the memory allocated by the following definition ?int (*x)[10];

4. What is the memory allocated by the following definition ?int (*x)();

5. In the following program segment#include<stdio.h>main(){int a=2;int b=9;int c=1;while(b){if(odd(b))c=c*a;a=a*a;b=b/2;}printf("%d\n",c);}How many times is c=c*a calculated?

6. In the program segment in question 5 what is the value of a at the end of the whileloop?

ACCENTURE

Page 15: C_C++

Acenture Technical Questions

1. pointer to structure.

2. static variable and difference b/w(const char *p,char const *p,const char* const p).

3 pass by value & reference.

4. string library functions(syntax).

5. Write a program to compare two strings without using the strcmp() function.

6. Write a program to concatenate two strings.

7. Write a program to interchange 2 variables without using the third one.

8. Write programs for String Reversal & Palindrome check .

9. Write a program to find the Factorial of a number.

10. Write a program to generate the Fibinocci Series.

11. Searching and sorting alogorithms with complexities

2)Then he asked to list the various types of storage classes and asked me to explain the scope & lifetime of each one..(Auto, Static, Register, Extern, and also mutable(only used for classes) ) 3) Right shift/Left shift + 1's complement concepts then asked me to give the output of this:- i = 10; int j = i >> 10; cout<<j;

4) Then, difference b/w char *str = "Hello"; char arr[] = "Hello";he started asking whether following statements getcomplied or not; arr++; // ERROR..its like a pointer constant *(arr + 1) = 's'; cout<<arr; // o/p: Hslloand other questions which i dont remember

6) Explain Primary Memory, Secondary Memory, Virtual Memory...etc etc..??

7) What happens when you run a programme.. he meant what all the basic steps that O/S would take??

Page 16: C_C++

8) Virtual functions/ Abstract classes/ Pointer functions

9) Asked me to write a recurssive factorial prog.

10) Then he gave me a prob. of inheritance. Asked me how u would invoke a base class member function using derived class pointer( that func is not a virtual func. && no virtual Base class inheritance

1. ------stores a log of changes made to db,which are then written to _,which are then written to _,which is used if db recovery is necc.a) db buffer share poolb) program global area,shared poolc) system global area,large pool d) redo log buffer,online redo log2. ----means allowing objects of difference types to be considered as examples of a higher level set :ans: Generalization3. The primary characteristic of key field is that it must be unique4. Manager-------------- --emp managed by   ans:one of many recursive relationship5. If a member initialiser is not provided for a member object of a class .The object - is called a) static fn   b) non static fn c) default constructor d) none6. class constest {  private:     const int i;  public:    constest():i(10)}7. Inheritance  b) abstract base class  c) specifies a way to to define a const member data  d) none8. Iimplement polymorphism when by object belonging to different class can respond to the same message in diff ways.  a) late binding  b)dynamic binding  c) dynamically created object  d) virtual fun9. Member function---------- and ----------- set and reset the format state of flags.   a) set,reset    b) set,get    c) set, unset d) set ,unsetf

10. #include<iostream.h>  struct abc     {       int i;       abc(int j)         { i=j;}

Page 17: C_C++

      public:      void display()       { cout<<i;}    }

  void main()   {      abc ob(10);      ob.disp();    }a)10  b) error : constructor is not accessiblec) abc: i not accessible d)none11. # include<iostream.h>class sample  {     public :     sample(int **pp)    {      p=pp;}   int **p;   int **sample:: *ptr=&sample ::p;

12. Theory question about far pointers.Hint: Far pointers are 4 bytes in size and local pointers are 2 bytes in size. important: i saw in a previous question paper of accenture which is in the chetana database, some lady wrote that size of an integer in C is 2 bytes and for C++ it is 4 bytes. This is absurd.The size of types is entirely dependent on the compiler used.for DOS Turbo C sizeof int is 2 and float is 4 bytes for windows borland C,C++ size of int is 4 bytes for linux gcc, size of int is 2 bytes. All these depends on the Operating system.Please keep this in mind.

Page 18: C_C++

13. Now some questions about extern variables.#include<stdio.h>main()  {   char str[]={"hell"};   int i;   for(i=0;i<5;i++)   printf("%c%c%c%c\n",str[i],i[str],*(str+i),*(i+str));   getch();  }   ans.   hhhh   eeee   llll  llll note that str[i] and i[str] are the same.in the question paper, the original word is "hello".

Some memory is allocated using memalloc and then realloc is called. and now to write the size  of the variable.better learn memalloc and realloc. what it does and syntax.

1. Given the following statement enum day = { jan = 1 ,feb=4, april, may} What is the value of may?      (a) 4      (b) 5      (c) 6      (d) 11      (e) None of the above

2. Find the output for the following C program      main()        {int x,j,k;         j=k=6;x=2;        x=j*k;        printf("%d", x);

3. Find the output for the following C program                                                               

fn f(x)        { if(x<=0)         return;         else f(x-1)+x;        }

6. Find the output for the following C program      int x=5;      y= x&y

Page 19: C_C++

9. What is the sizeof(long int)        (a) 4 bytes        (b) 2 bytes        (c) compiler dependent

(d) 8 bytes10. Which of the function operator cannot be over loaded           (a) <=           (b) ?:           (c) =           (d) *11. Find the output for the following C program          main()           {intx=2,y=6,z=6;             x=y==z;            printf(%d",x)              }                                            Section C Section C (Programming Skills)  Answer the questions based on the following program      1. In what case the prev was            (a) All cases            (b) It does not work for the last element            (c) It does not for the first element            (d) None of these    Answer the questions based on the following program         VOID FUNCTION(INT KK)         {KK+=20;          }           VOID FUNCTION (INT K)           INT MM,N=&M           KN = K           KN+-=10;             }2. What is the output of the following program

main()          { int var=25,varp;           varp=&var;           varp p = 10;           fnc(varp)           printf("%d%d,var,varp);           }              (a) 20,55              (b) 35,35              (c) 25,25              (d) 55,55  

6. On a machine where pointers are 4 bytes long, what happens when the following code is executed.         main()               {                int x=0,*p=0;

Page 20: C_C++

                x++; p++;                printf ("%d and %d\n",x,p);                 }           a) 1 and 1 is printed           b) 1 and 4 is printed           c) 4 and 4 is printed           d) causes an exception

8.  Consider the following program                 main()                      {                        int i=20,*j=&i;                        f1(j);                        *j+=10;                         f2(j);                         printf("%d and %d",i,*j);                                                                                              }                         f1(k)                         int *k;                             {                               *k +=15;                               }                                   f2(x)                                   int *x;                              {                                 int m=*x,*n=&m;                                 *n += 10;                                 }                The values printed by the program will be                a) 20 and 55                b) 20 and 45                c) 45 and 45                d) 45 and 55                e) 35 and 359.  what is printed when the following program is compiled and executed?           int           func (int x)              {                if (x<=0)            return(1);            return func(x -1) +x;                                                                                                                }              main()                    {                       printf("%d\n",func(5));                      }            a) 12            b) 16

Page 21: C_C++

            c) 15            d) 11

1. 1.What is the output of the following code?      x=0;y=1;      for(j=1;j<4;j++){         x=x+j;         y*=j;            } if(fp == fopen(\"dfas\",\"r\") = = NULL), what is the value of fp   a. NULL b. 0 c. 1 d. 0 or 12. #define sqr(x) x*x, what is value of j if j == 2 * sqr(3 + 4)3. #define FILENAME(extension) test_##extension, how will it print FILENAME(back)a. test_back b. test_#back c. test_##back d. ??4. char *p == \"hello world\"p[0] == \'H\', what will be printf(\"%s\", p);a. Hello world b. hello world c. H d. compile error5. int fun(), how do u define pointer to this function ??6. what is ment by int (* xyz)[13]7. what is true froma. base call ferernece is compatible with child classb. child class reference is compatible with base classc. no reference to classd. ??8. class b  {  }  class a    {     friend class b    }then what is turea. a can access all protected and public members in bb. b can access all protected and public members in ac. a can access all members of ad. b can access all members of b

Page 22: C_C++

9. What is the output #includemain()      {   int n=0;   int i;   i=2;  switch(1)       {       case 0:do{       case 1:n++;       case 2:n++;      }           while(--i>0);    {        printf(\"n==%d\",n);        }}a. compile error      b. 4     c. 1      d. 0 10. Write a minimal C++ program .11. (a) Talk about yourself(b) What are your strengths.(c) Where do you think you have to improve.(d) Where do you see yourself after 5 years12. What is an OS ?13. What is a Data Structure ?14. It is a an abstract data type where some operations can be defined and performed on the data. It makes the task of a programmer easy coz it has all the set of data and operations at a particular place 15. What is OOP. 16. What is Object Oriented Analysis and design. 17. How do u communicate between object and class. 18. What is the role Software in the real life in current scenario. 19. What is object and how it is similar to real life entity What is extranet, intranet, internet

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

Page 23: C_C++

                        }                     }   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 35) Which of the following operators cannot be overloaded in C++? A) ?:   B)[]   C) -   D) None of These

8.ex:define max 10 main(){ int a,b; int *p,*q; a=10;b=19; p=&(a+b); q=&max;} Q a)error in p=&(a+b) b)error in p=&max c)error in both d) no error 

. Given a cube, with different colors on its faces, and then is cutinto 64 pieces, and the questions relate to the colors of different colored small cubes.

2. A few ladies and gents sit around table in some given order and 4questions are about their seating arrangement with some restrictions.

4. A problem related to seating arrangement of 4 people ( 2 ladies and2 gents) with some restrictions

4.sum(x)=1+ 1+2+ 1+2+3+ .....xwrite the condition'?'{for(i=0;i<?;i++)for(j=0;j<?;j++)sum+=z}

1. find(int x,int y){ return ((x<y)?0:(x-y)):}

Page 24: C_C++

call find(a,find(a,b)) use to find(a) maximum of a,b(b) minimum of a,b(c) positive difference of a,b(d) sum of a,b

2. integer needs 2bytes , maximum value of an unsigned integer is (a) { 2 power 16 } -1(b) {2 power 15}-1(c) {2 power16} (d) {2 power 15} 

3.y is of integer type then expression 3*(y-8)/9 and (y-8)/9*3 yields same value if (a)must yields same value(b)must yields different value (c)may or may not yields same value(d) none of the above

4. 5-2-3*5-2 will give 18 if (a)- is left associative,* has precedence over -(b) - is right associative,* has precedence over - (c) - is right associative,- has precedence over *(d)- is left associative,- has precedence over *

5. printf("%f", 9/5);prints (a) 1.8,(b) 1.0,(c) 2.0,(d) none

6. if (a=7)printf(" a is 7 ");else printf("a is not 7");prints (a) a is 7,(b) a is not 7,(c) nothing,(d) garbage.

7. if (a>b)if(b>c)s1;else s2;s2 will be executed if (a) a<= b,(b) b>c,

Page 25: C_C++

(c) b<=c and a<=b,(d) a>b and b<=c.

8. main(){ inc(); ,inc(); , inc(); }inc(){ static int x;printf("%d", ++x);}prints(a) 012,(b) 123,(c) 3 consecutive unprectiable numbers(d) 111.

9.preprocessing is done

(a) either before or at begining of compilation process(b) after compilation before execution(c) after loading(d) none of the above.

10. printf("%d", sizeof(""));prints (a) error(b)0(c) garbage(d) 1.

11.main(){ int a=5,b=2;printf("%d", a+++b);}

(a) results in syntax,(b) print 7,(c) print 8,(d) none,12. process by which one bit patten in to another by bit wise operation is (a) masking,(b) pruning,(c) biting,(d) chopping,

13.value of automatic variable that is declared but not intializedwill be (a) 0,

Page 26: C_C++

(b) -1,(c) unpredictable,(d) none,

14. int v=3, *pv=&v;printf(" %d %d ", v,*pv);output will be (a) error(b) 3 address of v,(c) 3 3(d) none.

15. declarationenum cities{bethlehem,jericho,nazareth=1,jerusalem}assian value 1 to(a) bethlehem(b) nazareth (c)bethlehem & nazareth(d)jericho & nazareth

16. #include<conion.h>#include<stdio.h>void main(){char buffer[82]={80};char *result;printf( "input line of text, followed by carriage return :\n");result = cgets(buffer);printf("text=%s\n",result);}(a) printf("length=%d",buffer[1]); (b) printf("length=%d",buffer[0]);(c) printf("length=%d",buffer[81]);(d) printf("length=%d",buffer[2]);

Page 27: C_C++

17. consider scanf and sscanf function , which is true

(a) no standard function called sscanf(b) sscanf(s,...) is equivalent to scanf(...) except thatinput charecter are taken from string s.(c) sscanf is equivalent to scanf.(d) none of above.

18. #include <stdio.h>main(){char line[80];scanf("%[^\n]",line);printf("%s",line);}what scanf do ?(a) compilation error . illegal format string.(b) terminates reading input into variable line.(c) and (d) other two options.

19. problem was big so i couldn't remember . simple one.

20 . ceil(-2.8) ?(a) 0(b) -3.0(c) -2.0(d) 2

21. for( p=head; p!=null; p= p -> next)free(p);

(a) program run smooth.(b) compilation error.(c) run time error.(d) none of above.

22. int x[3][4] ={{1,2,3},{4,5,6},{7,8,9}}(a) x[2][1] = x[2][2] =x[2][3] = 0(b) value in fourth column is zero (c) value in last row is zero(d) none of above.

23. problem was big so i couldn't remember . simple one.

24. main (){ 

Page 28: C_C++

printf("%u" , main());}(a) print garbage.(b) execution error(c) printing of starting address of function main.(d) infinite loop.

25 . int a, *b = &a, **c =&b;.............a=4;** c= 5;

(a) doesnot change value of a(b) assign address of c to a.(c) assign value of b to a.(d) assign 5 to a.

26.problem was big so i couldn't remember . simple one.

27.problem was big so i couldn't remember . simple one.

28 . answer : swapping of values .

29 . simple one.

30 . i =5;i= (++i)/(i++);printf( "%d" , i);prints ,(a) 2(b) 5(c) 1(d) 6   

4.define max 10 Main() {int a,b;int *p,*q; a=10;b=19; p=&(a+b); q=&max; } (a)error in p=&(a+b) (b)error in p=&max (c)error in Both (d)no error

5.if(a>b) if(b>c) s1;

Page 29: C_C++

else s2; s2 will be executed if (a)a<=b (b)b>c, (c)b<=c and a<=b, (d) a>b and b<=c

6.printf(“%d”,sizeof(“”)); Prints(a)error (b)0 (c)garbage (d)1

7.main() {int a=5,b=2; Printf(“%d”,a+++b); }(a)results in syntax (b)print 7 (c)print 8 (d) none

8.process by which one bit pattern in to another by bit wise operation is(a)masking (b) pruning (c)biting (d)chopping

9.Value of automatic variable that is declared but not Initialized will be(a)0 (b)-1 (c)unpredictable (d) none

10.int v=3,*pv=&v; Printf(“%d %d”,v,*pv); Output will be(a)error (b)3 address of v (c)3 3 (d)none

- Difference between array and pointer. Among them which one is dynamic?- Difference between array and structure- Difference between structure and union.- Name the data types in C- Syntax of Switch- What is a datatype?- Write any C program.- What is the range of short int?- Difference between C and Java?- Difference between C and C++?- What is a pointer?- What is an array?- What is structure?- What is union?- Write the palindrome program in C- Program on concatenation of strings without using strcat().- Program on reversing a given string without using strrev().- Program on comparing two strings without using strcmp().- Program on bubble sort.- Program to find the factorial of a number.- Program to reverse a number.- To print average of 5 numbers using an array.- What r storage classes in C? Why r they required?- How many sorting techniques r there in C? What r they?

Page 30: C_C++

- Why so many sorting techniques r required?- Using functions write a C program to find the addition of two numbers.- Write a program for reversing a string using pointers- Write any one sorting algorithm?- Using functions write a C program to find the product of two numbers- What is Stack? What order does it follow?- What is Queue? What order does it follow?- Difference between function and procedure- What is binary tree? Does it have any condition?- Syntax of while, do while, for, if and small programs using them- What is the difference between while and do while loops?- A program, which is written in C, is given and was asked to find out the error.- Limitations of queue?- Tell what u know about data structures.- What is the difference between structure and data structure?- Call by value and Call by reference? Write a program on them.-    i= -127.4327 http://www.ChetanaS.org-    Command used in C for reading an element-    Command used in C for printing an element-    What is your favorite subject and why????????-    Name the subjects which u studied in last semester or the subject's u r studying presently -    Rate yourself in C.

1) C++ constructors and destructors are used for......2) A program (greatest of 3 nos) in C++ was given.o/p was asked.4) What is the o/p of the following program?    main ()    {        int a[5]={1,2,3,4,5};        printf ("%d", &a[0]-&a[3]);    }

Page 31: C_C++

5) Which of the following is a constructor?   1)    hello( ){ }  2) hello( ){ 3}  3)hello( ){1,2,3}  que not exactly the same.. Same model..what is diff b/w pointer and array?Ch eta naSoutput of this:main(){const int *p=6;printf("%d",++*p);}like dat.. some more r there.. i dint remember..next hr round.

2) What is the output of the following program main () { unsigned int i;

for (i = 10; i >= 0; i--) printf ("%d", i);

} a) prints numbers 10 - 0 b) prints nos 10 - 1 c) d) goes into infinite loop

17) How many x's are printed? for (i = 0, j = 10; i < j; i++, j--) printf ("x"); a) 10 b) 5 c) 4 d) none

18) output? main () { int i = 2, j = 3, k = 1; swap (i, j) printf ("%d %d", i, j); } swap (int i, int j) { int temp; temp = i; i = j; j = temp; } YOU KNOW THE ANSWER

Page 32: C_C++

19) main () { int i = 2; twice (2); printf ("%d", i); } twice (int i) { bullshit }

int i, b[] = {1, 2, 3, 4, 5}, *p; p = b; ++*p; p += 2;

20) What is the value of *p; a) 2 b) 3 c) 4 d) 521) What is the value of (p - (&p - 2))? a) b) 2 c) d) 49) main () { int ones, twos, threes, others; int c;

ones = twos = threes = others = 0;

while ((c = getchar ()) != EOF) {

switch (c) { case '1': ++ones; case '2': ++twos; case '3': ++threes;

break; default: ++others;

break; }

} printf ("%d %d", ones, others); }

if the input is "1a1b1c" what is the output? a. 13 b. c. 33 d. 31

1) Which of these is an invalid dataname? a) wd-count b) wd_count

Page 33: C_C++

c) w4count d) wdcountabcd

2) What is the output of the following program main () { unsigned int i;

for (i = 10; i >= 0; i--) printf ("%d", i);

} a) prints numbers 10 - 0 b) prints nos 10 - 1 c) d) goes into infinite loop

11) What is the value of the following expression? i = 1; i << 1 % 2 a) 2 b) c) 1 d) 0

12) What is the value of the following expression? i = 1; i = (i <<= 1 % 2) a) 2 b) c) 0 d) erroneous syntax

What is the result?13) *A + 1 - *A + 3 a) - b) -2 c) 4 d) none of the above

14) &A[5] - &A[1]? a) b) c) 4 d)15) C allows a) only call by value b) only call by reference c) both d) only call by value and sometimes call by reference16) The following statement is " The size of a struct is always equal to the sum

of the sizes of its members" a) valid b) invalid c) can't say17) How many x's are printed? for (i = 0, j = 10; i < j; i++, j--) printf ("x"); a) 10 b) 5 c) 4 d) none

18) output? main () { int i = 2, j = 3, k = 1;

Page 34: C_C++

swap (i, j) printf ("%d %d", i, j); } swap (int i, int j) { int temp; temp = i; i = j; j = temp; } YOU KNOW THE ANSWER

19) main () { int i = 2; twice (2); printf ("%d", i); } twice (int i) { bullshit }

int i, b[] = {1, 2, 3, 4, 5}, *p; p = b; ++*p; p += 2;

20) What is the value of *p; a) 2 b) 3 c) 4 d) 521) What is the value of (p - (&p - 2))? a) b) 2 c) d)

23) x = fopen (b, c) what is b? a) pointer to a character array which contains the filename b) filename whithin double quotes c) can be anyone of the above d) none

24) x = malloc (y). Which of the following statements is correct. a) x is the size of the memory allocated b) y points to the memory allocated c) x points to the memory allocated d) none of the above

25) which is the valid declaration? a) #typedef struct { int i;}in; b) typedef struct in {int i;}; c) #typedef struct int {int i;}; d) typedef struct {int i;} in;

Page 35: C_C++

26) union { int no; char ch; } u; What is the output? u.ch = '2'; u.no = 0; printf ("%d", u.ch); a) 2 b) 0 c) null character d) none

27) Which of these are valid declarations? i) union { ii) union u_tag {

int i; int i; int j; int j;

}; };

iii) union { iv) union { int i; int i; int j; int j; FILE k; }u;

};

a) all correct b) i, ii, iv c) ii & iv d)

28) p and q are pointers to the same type of dataitems. Which of these are valid? i) *(p+q) ii) *(p-q) iii) *p - *q

a) all b) c) iii is valid sometimes

29) which are valid? i) pointers can be added ii) pointers can be subtracted iii) integers can be added to pointers a) all correct b) only i and ii

30) int *i; float *f; char *c; which are the valid castings? i) (int *) &c ii) (float *) &c iii) (char *) &i

Page 36: C_C++

31) int i = 20; printf ("%x", i); what is the output? a) x14 b) 14 c) 20 d) none of the above

32) main () { char *name = "name"; change (name); printf ("%s", name); } change (char *name) { char *nm = "newname"; name = nm; } what is the output? a) name b) newname c) name = nm not valid d) function call invalid

33) char name[] = {'n', 'a', 'm', 'e'} printf ("name = \n%s", name); a) name = name b) name = followed by funk characters c) name = \nname d) none

34) int a = 0, b = 2;if (a = 0)

b = 0;else

b *= 10; what is the value of b? a) 0 b) 20 c) 2 d) none

Page 37: C_C++

35) int x = 2, y = 2, z = 1; what is the value of x afterh the following statmements? if (x = y%2) z = crap else crap

a) 0 b) 2 c)1 d)none

37) output? initially n = -24; printd (int n) { if (n < 0) {

printf ("-"); n = -n;

} if (n % 10)

printf ("%d", n); else

printf ("%d", n/10);

printf ("%d", n); } a. -24 b.24 c. d.-224

38) float x, y, z; scanf ("%f %f", &x, &y);

if input stream contains "4.2 3 2.3 ..." what will x and y contain after scanf? a. 4.2, 3.0 b. 4.2, 2.3 c. d.

39) #define max(a,b) (a>b?b:a) #define squre(x) x*x

int i = 2, j = 3, k = 1; printf ("%d %d", max(i,j), squre(k));

output? a.32 b.23 c.31 d.13

Page 38: C_C++

40) struct adr { char *name; char *city; int zip; }; struct adr *adradr; which are valid references?

i) adr->name X ii) adradr->name iii) adr.zip X iv) adradr.zip

41) main (x, y) int x, char *y[]; { printf ("%d %s", x, y[1]); } output when invoked as prog arg1 a. 1 prog b. 1 arg1 c. 2 prog d. 2 arg1

42) extern int s; int t; static int u; main () { } which of s, t and u are available to a function present in another

file a. only s b. s & t c. s, t, u d. none

43) main () { } int a; f1(){} f2(){}

which of the functions is int a available for? a. all of them b. only f2 c. only f1 d. f1 and f2 only

int a = 'a', d = 'd'; char b = "b", c = "cr";

Page 39: C_C++

main () { mixup (a, b, &c); } mixup (int p1, char *p2, char **p3) { int *temp; ....doesnt matter..... }

44) what is the value of a after mixup? a. a b.b c.c d.none of the above

45) what is the value of b after mixup? a. a b.b c.c d.none of the above

46) main () { char s[] = "T.C.S", *A; print(s); } print (char *p) { while (*p != '\0') {

if (*p != ".") printf ("%s", *p); p++;

} } output? a.T.C.S b.TCS c. d. none of the above

47) a question on do ... while48) a question on % operator

Page 40: C_C++

49) main () { int ones, twos, threes, others; int c;

ones = twos = threes = others = 0;

while ((c = getchar ()) != EOF) {

switch (c) { case '1': ++ones; case '2': ++twos; case '3': ++threes;

break; default: ++others;

break; }

} printf ("%d %d", ones, others); }

if the input is "1a1b1c" what is the output? a. 13 b. c. 33 d. 31

1. The C language terminator is (a) semicolon(b) colon(c) period(d) exclamation mark2. What is false about the following -- A compound statement is (a) A set of simple statments(b) Demarcated on either side by curly brackets(c) Can be used in place of simple statement(d) A C function is not a compound statement.3. What is true about the following C Functions(a) Need not return any value(b) Should always return an integer(c) Should always return a float(d) Should always return more than one value4. Main must be written as(a) The first function in the program(b) Second function in the program(c) Last function in the program(d) Any where in the program5. Which of the following about automatic variables within a function is correct ?

Page 41: C_C++

(a) Its type must be declared before using the variable(b) Tthey are local(c) They are not initialised to zero(d) They are global6. Write one statement equivalent to the following two statements x=sqr(a);return(x);Choose from one of the alternatives(a) return(sqr(a));(b) printf("sqr(a)");(c) return(a*a*a);(d) printf("%d",sqr(a));7. Which of the following about the C comments is incorrect ?(a) Ccommentscan go over multiple lines(b) Comments can start any where in the line(c) A line can contain comments with out any language statements(d) Comments can occur within comments 8. What is the value of y in the following code?x=7;y=0; if(x=6) y=7; else y=1; (a) 7(b) 0(c) 1(d) 69. Read the function conv() given belowconv(int t){ int u; u=5/9 * (t-32);return(u);} What is returned(a) 15(b) 0(c) 16.1(d) 2910. Which of the following represents true statement either x is in the range of 10 and 50 or y is zero(a) x >= 10 && x <= 50 || y = = 0(b) x<50(c) y!=10 && x>=50(d) None of these

Page 42: C_C++

11. Which of the following is not an infinite loop ?(a) while(1)\{ ....}(b) for(;;){...}(c) x=0; do{/*x unaltered within the loop*/.....}while(x = = 0);(d) # define TRUE 0...while(TRUE){....} 12. What does the following function print?func(int i){ if(i%2)return 0; else return 1;}main(){int =3;i=func(i);i=func(i);printf("%d",i);}(a) 3(b) 1(c) 0(d) 213. How does the C compiler interpret the following two statementsp=p+x;q=q+y;(a) p=p+x;     q=q+y (b)p=p+xq=q+y(c)p=p+xq;    q=q+y (d)p=p+x/q=q+yFor questions 14,15,16,17 use the following alternativesa.intb.charc.stringd.float14. '9'15. "1 e 02"16. 10e0517. 15 18. Read the folllowing code

Page 43: C_C++

# define MAX 100# define MIN 100........if(x>MAX)x=1;else if(x<MIN)x=-1;x=50;if the initial value of x=200,what is the value after executing this code?(a) 200(b) 1(c) -1(d) 50 19. A memory of 20 bytes is allocated to a string declared as char *sthen the following two statements are executed:s="Entrance"l=strlen(s);what is the value of l ?(a)20(b)8(c)9(d)2120. Given the piece of codeint a[50];int *pa;pa=a; To access the 6th element of the array which of the following is incorrect?(a) *(a+5)(b) a[5](c) pa[5](d) *(*pa + 5} 21. Consider the following structure:struct num nam{int no;char name[25];}struct num nam n1[]={{12,"Fred"},{15,"Martin"},{8,"Peter"},{11,Nicholas"}};..........printf("%d%d",n1[2],no,(*(n1 + 2),no) + 1);What does the above statement print?(a) 8,9(b) 9,9(c) 8,8(d) 8,unpredictable value22. Identify the in correct expression(a) a=b=3=4;(b) a=b=c=d=0;

Page 44: C_C++

(c)float a=int b=3.5;(d)int a; float b; a=b=3.5;23. Regarding the scope of the varibles;identify the incorrect statement:(a)automatic variables are automatically initialised to 0(b)static variables are are automatically initialised to 0(c)the address of a register variable is not accessiable(d)static variables cannot be initialised with any expression24. cond 1?cond 2?cond 3?:exp 1:exp 2:exp 3:exp 4;is equivalent to which of the following?(a)if cond 1exp 1;else if cond 2exp 2;else if cond 3exp 3;else exp 4;(b) if cond 1if cond 2if cond 3exp 1; else exp 2;else exp 3;else exp 4;(c) if cond 1 && cond 2 && cond 3exp 1 |exp 2|exp 3|exp 4;(d) if cond 3exp 1;else if cond 2 exp 2;else if cond 3 exp 3;else exp 4; 25. The operator for exponencation is(a) **(b) ^(c) % (d) not available26. Which of the following is invalid(a) a+=b(b) a*=b(c) a>>=b(d) a**=b

Page 45: C_C++

27. What is y value of the code if input x=10y=5;if (x==10)else if(x==9)else y=8;(a)9(b)8(c)6(d)728. What does the following code do?fn(int n,int p,int r){static int a=p;switch(n){case 4:a+=a*r;case 3:a+=a*r;case 2:a+=a*r;case 1:a+=a*r;}}(a)computes simple interest for one year(b)computes amount on compound interest for 1 to 4 years(c)computes simple interest for four year (d)computes compound interst for 1 year29. a=0;while(a<5)printf("%d\\n",a++);How many times does the loop occurs?(a)infinite(b)5(c)4(d)630. How many times does the loop iterated ?for (i=0;i=10;i+=2)printf("Hi\\n");(a)10(b) 2(c) 5(d) None of these31. What is incorrect among the followingA recursive function(a) calls itself(b) is equivalent to a loop(c) has a termination condition(d) does not have a return value at all  32. Which of the following go out of the loop if expn 2 becoming false(a) while(expn 1)\{...if(expn 2)continue;}(b) while(!expn 1)\{if(expn 2)continue;...}(c) do{..if(expn 1)continue;..}while(expn 2);(d) while(!expn 2)\{if(expn 1)continue;..\}

33. Consider the following program

Page 46: C_C++

main(){unsigned int i=10;while(i>=0){printf("%u",i)i--;}}How many times the loop will get executed(a)10(b)9(c)11(d)infinite34.Pick out the add one out(a) malloc()(b) calloc()(c) free()(d) realloc() 35.Consider the following programmain(){int a[5]={1,3,6,7,0};int *b;b=&a[2];}The value of b[-1] is(a) 1(b) 3(c) -6(d) none36. # define prod(a,b)=a*bmain(){int x=2;int y=3; printf("%d",prod(x+2,y-10)); }the output of the program is (a) 8(b) 6(c) 7(d) None37.Consider the following program segmentint n,sum=1;switch(n){case 2:sum=sum+2;case 3:sum*=2;break;default:sum=0;} If n=2, what is the value of sum(a) 0 (b) 6 (c) 3 (d) None of these

38. Identify the incorrect one1.if(c=1)2.if(c!=3)

Page 47: C_C++

3.if(a<b)then4.if(c==1)(a) 1 only(b) 1&3(c) 3 only(d) All of the above39. The format specified for hexa decimal is(a) %d(b) %o(c) %x(d) %u40. Find the output of the following programmain(){int x=5, *p;p=&xprintf("%d",++*p); }(a) 5(b) 6(c) 0(d) none of these41.Consider the following C codemain(){int i=3,x;while(i>0){x=func(i);i--; }int func(int n){static sum=0;sum=sum+n;return(sum);}The final value of x is(a) 6(b) 8(c) 1(d) 3

Page 48: C_C++

43. Int *a[5] refers to(a) array of pointers(b) pointer to an array(c) pointerto a pointer (d) none of these

44.Which of the following statements is incorrect(a) typedef struct new{int n1;char n2;} DATA;(b) typedef struct {int n3;char *n4;}ICE;(c) typedef union{ int n5;float n6;} UDT;(d) #typedef union { int n7; float n8;} TUDAT; 18) What will be the result of the following program?main(){char p[]="String";int x=0;

if(p=="String"){printf("Pass 1");if(p[sizeof(p)-2]=='g')printf("Pass 2");elseprintf("Fail 2");}else{printf("Fail 1");if(p[sizeof(p)-2]=='g')printf("Pass 2");elseprintf("Fail 2");}}

a) Pass 1, Pass 2 b) Fail 1, Fail 2 c) Pass 1, Fail 2 d) Fail 1, Pass 2e) syntax error during compilation 

32. What will be the result of the following program?main()

Page 49: C_C++

{char p[]="String";int x=0;if(p=="String"){printf("Pass 1");if(p[sizeof(p)-2]=='g')printf("Pass 2");elseprintf("Fail 2");}else{printf("Fail 1");if(p[sizeof(p)-2]=='g')printf("Pass 2");elseprintf("Fail 2");} }a) Pass 1, Pass 2 b) Fail 1, Fail 2 c) Pass 1, Fail 2 d) Fail 1, Pass 2e) syntax error during compilation

54). Input a,bs=0;c=a;d=b;while(d<>0){s=s+c;d=d-1;}Print s

for given values of a,b find the output 5questions for different values of a,b main(){int a[]={ 2,4,6,8,10 };int i;change(a,5);for( i = 0; i <= 4; i++)printf("\n %d",a[i]);}change( int *b, int n){int i;for( i = 0; i < n; i++)*(b+i) = *(b+i) + 5;}2. Find the output for the following C programmain{

Page 50: C_C++

int x,j,k;j=k=6;x=2;x=j*k;printf("%d", x);}3. Find the output for the following C programfn f(x) { if(x<=0)return;else f(x-1)+x;}6. Find the output for the following C programint x=5;y= x&y

9. What is the sizeof(long int)(a) 4 bytes (b) 2 bytes (c) compiler dependent (d) 8 bytes

 10. Which of the function operator cannot be over loaded(a)  <= (b) ?: (c) == (d) *

11. Find the output for the following C programmain(){int x=2,y=6,z=6;x=y==z;printf(%d",x)}1. If you are not having a sizeof operator in C, how will you get to know the size of an int ?

2. Write a macro to set the nth bit ?

3. Can you use a variable in a file using extern which is defined as both static and global in base file?

4. When we declare union in C, how is the size of union allocated in the memory?

5. What is the boundary problem in allocation of size of structures?

6. Data Structures:- a. Write a program to reverse a linked-list.

Uma, before interview, practise it on a paper as many here couldn't write the code at the time of interview. b. Some trees question...what is balanced binary tree?..etc..

To Some students, one software panel asked about t

main(){ int x=10,y=15;

Page 51: C_C++

x=x++; y=++y; printf("%d %d\n",x,y);}----------------------------------------------------------------------

int x;main(){ int x=0; { int x=10; x++; change_value(x); x++; Modify_value(); printf("First output: %d\n",x); } x++; change_value(x); printf("Second Output : %d\n",x); Modify_value(); printf("Third Output : %d\n",x);}

Modify_value(){ return (x+=10);}

change_value(){ return(x+=1);}----------------------------------------------------------------------------main(){ int x=20,y=35; x = y++ + x++; y = ++y + ++x; printf("%d %d\n",x,y);}-----------------------------------------------------------------------main(){ char *p1="Name"; char *p2; p2=(char *)malloc(20); while(*p2++=*p1++); printf("%s\n",p2);

Page 52: C_C++

}----------------------------------------------------------------------main(){ int x=5; printf("%d %d %d\n",x,x<<2,x>>2);}--------------------------------------------------------------------

#define swap1(a,b) a=a+b;b=a-b;a=a-b;main(){ int x=5,y=10; swap1(x,y); printf("%d %d\n",x,y); swap2(x,y); printf("%d %d\n",x,y);}

int swap2(int a,int b){ int temp; temp=a; b=a; a=temp; return;}----------------------------------------------------------------------main(){ char *ptr = "Ramco Systems"; (*ptr)++; printf("%s\n",ptr); ptr++; printf("%s\n",ptr);}

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

Page 53: C_C++

#include<stdio.h>main(){ char s1[]="Ramco"; char s2[]="Systems"; s1=s2; printf("%s",s1);}-----------------------------------------------------------------#include<stdio.h>main(){ char *p1; char *p2; p1=(char *) malloc(25); p2=(char *) malloc(25); strcpy(p1,"Ramco"); strcpy(p2,"Systems"); strcat(p1,p2); printf("%s",p1);}

main(){ int x=10,y=15; x=x++; y=++y; printf("%d %d\n",x,y);}----------------------------------------------------------------------int x;main(){ int x=0; { int x=10; x++; change_value(x); x++; Modify_value(); printf("First output: %d\n",x); } x++; change_value(x); printf("Second Output : %d\n",x); Modify_value(); printf("Third Output : %d\n",x);}Modify_value(){

Page 54: C_C++

return (x+=10);}

change_value(){ return(x+=1);}

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

main(){ int x=20,y=35; x = y++ + x++; y = ++y + ++x; printf("%d %d\n",x,y);}-----------------------------------------------------------------------main(){ char *p1="Name"; char *p2; p2=(char *)malloc(20); while(*p2++=*p1++); printf("%s\n",p2);}----------------------------------------------------------------------main(){ int x=5; printf("%d %d %d\n",x,x<<2,x>>2);}

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

#define swap1(a,b) a=a+b;b=a-b;a=a-b;main(){ int x=5,y=10; swap1(x,y); printf("%d %d\n",x,y); swap2(x,y); printf("%d %d\n",x,y);}

int swap2(int a,int b){ int temp; temp=a;

Page 55: C_C++

b=a; a=temp; return;}----------------------------------------------------------------------

main(){ char *ptr = "Ramco Systems"; (*ptr)++; printf("%s\n",ptr); ptr++; printf("%s\n",ptr);}

---------------------------------------------------------------------#include<stdio.h>main(){ char s1[]="Ramco"; char s2[]="Systems"; s1=s2; printf("%s",s1);}

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

#include<stdio.h>main(){ char *p1; char *p2; p1=(char *) malloc(25); p2=(char *) malloc(25); strcpy(p1,"Ramco"); strcpy(p2,"Systems"); strcat(p1,p2); printf("%s",p1);}

Page 56: C_C++

10. include<stdio.h>void swap(int*,int*);main(){int arr[8]={36,8,97,0,161,164,3,9}for (int i=0; i<7; i++)for (int j=i+1; j<8;j++)if(arr[i]<arr[j]) swap(&arr[i],&arr[j]);}void swap(int*x,int*y){int temp; static int cnt=0;temp= *x;*x=*y;*y=temp;cnt++;}

cnt = ?a) 7 b) 15 c)1 d)

 11. int main(){FILE *fp;fp=fopen("test.dat","w");fprintf(fp,'hello\n");fclose(fp);fp=fopen ("test.dat","w");fprintf (fp, "world");fclose(fp);return 0;}

if text.dat file is already present after compiling and execution how many bytes does the file occupy

a) 0 bytes b)5 bytes c)11 bytes d)data is insufficient

Page 57: C_C++

12. f1(int*x,intflag)int *y;*y=*x+3;switch(flag){case 0:.....................break;case 1:*x=*y;break;case 2:..........................break;}return(*y)main(){*x=5;i=f1(x,0); j=f1(x,1);printf("%.........",i,j,*x);}

what is the output?a) 8 8 8 b) 5 8 8 c) 8 5 8 d)

1.Write a program to insert a node in a sorted linked list.

2.Write a program to implement the Fibonacci series.

3.Write a program to concatenate two circular linked lists into a single circular list.

4.A function even_odd_difference()passes the array of elements.Write a program to calculate the difference of the two sums of which one sum adds the elements of odd ones and another adds the elments of even ones.

5.Write a program to reverse a linked list.

1.void main() {char *s=”Hello World”;printf(“%c”,s);}File fp,fs;fp=fopen(“tc.dat”,”w”);fs=fopen(“tc.dat”,”w”);putch(‘A’,fp);putch(‘B’,fs); What will happen?4.switch(float value) this is compiler error.

Page 58: C_C++

5.int a[5]={1,2,3,4,5};int *p=a+1;int *q=a+5;int dif=q-p;

1. Find the o/p of the following codemain(){  char *ptr;  char a[]="abcdefghijkl";  ptr=a;  printf("%s",ptr+5);}

A. fghijkl B. ghijkl C. hijkl D. fghij2. What will be the result after the execution of the following program?void main(){   int a[4][2];  int b=0,x;  int i,y;  for(i=0;i<4;i++)      for(y=0;y<2;y++)             a[i][y]=b++;   printf("\n%d",*(*(a+2)-1));}A. 3 B. 4 C. 2 D. 53. How will the values a and b be printed wrt to following code? int main(){            int a = 3.9e-3;int b = 3.9e+3;            printf("%d%d",a,b);            return 0;}

A. 0,0B. Illegal storing of float value in integer varaibleC. 0,3900D. undefined

Page 59: C_C++

4. Predict the behaviour of the comma operator wrt to the code below.main(){abc((200,100));}abc(int j){printf("j = %d",j);}

A. 200B. 100C. 3005 Does the following fragment can be used to calculate the factorial of a number?#define FACT(n) (n>1)?n*FACT(n-1):1

A. TrueB. False

1. #include<iostream.h>  struct abc     {       int i;       abc(int j)         { i=j;}      public:      void display()       { cout<<i;}    }  void main()   {      abc ob(10);      ob.disp();    }

a)10  b) error : constructor is not accessiblec) abc: i not accessible d)none

2. # include<iostream.h>class sample  {     public :     sample(int **pp)    {      p=pp;}   int **p;   int **sample:: *ptr=&sample ::p;

3. Theory question about far pointers.

Hint: Far pointers are 4 bytes in size and local pointers are 2 bytes in size. important: i

Page 60: C_C++

saw in a previous question paper of accenture which is in the chetana database, some lady wrote that size of an integer in C is 2 bytes and for C++ it is 4 bytes. This is absurd.The size of types is entirely dependent on the compiler used.for DOS Turbo C sizeof int is 2 and float is 4 bytes for windows borland C,C++ size of int is 4 bytes for linux gcc, size of int is 2 bytes. All these depends on the Operating system.Please keep this in mind.

1.What is the output of the following code?             x=0;y=1; for( j=1;j<4;j++)

{                   x=x+j;                   y*=j;            }6.main(){ float fl = 10.5; double dbl = 10.5 if(fl ==dbl)     printf(“UNITED WE STAND”); else    printf(“DIVIDE AND RULE”) } what is the output?

a)compilation error b)UNITED WE STANDc)DIVIDE AND RULE d)linkage error.

  7.main(){ static int ivar = 5; printf(“%d”,ivar--); if(ivar) main(); }   what is the output?

a)1 2 3 4 5 b) 5 4 3 2 1 c)5 d)compiler error:main cannot be recursive function.

 

Page 61: C_C++

8.main() { extern int iExtern; iExtern = 20; printf(“%d”,iExtern); } what is the output?

a)2 b) 20 c)compile error  d)linker error          9..#define clrscr() 100 main(){ clrscr(); printf(“%d\n\t”, clrscr()); } what is the output?

a)100 b)10 c)compiler error d)linkage error   10.main() { void vpointer; char cHar = ‘g’, *cHarpointer = “GOOGLE”; int j = 40; vpointer = &cHar; printf(“%c”,*(char*)vpointer); vpointer = &j; printf(“%d”,*(int *)vpointer); vpointer = cHarpointer; printf(“%s”,(char*)vpointer +3); } what is the output?

a)g40GLE  b)g40GOOGLE c)g0GLE d)g4GOO   11.#define FALSE -1 #define TRUE 1 #define NULL 0 main(){ if(NULL)     puts(“NULL”); else if(FALSE)     puts(“TRUE”); else     puts(“FALSE”); } what is the output?

a)NULL b)TRUE c)FALSE d)0   12.main() {

Page 62: C_C++

int i =5,j= 6, z; printf(“%d”,i+++j); } what is the output?

a)13 b)12 c)11 d)compiler error 13.main() { int  i ; i = accumulator(); printf(“%d”,i); } accumulator(){ _AX =1000; } what is output?

a)1 b)10 c)100 d)1000   14.main() { int i  =0; while(+(+i--)!= 0) i-                  = i++; printf(“%d”,i); } what is the output?

a)-1 b)0 c)1 d)will go in an infinite loop   15.main(){ int i =3; for(; i++=0;) printf((“%d”,i); } what is the output?

a)1 b)2 c)1 2 3 d)compiler error value required.   16.main(){ int i = 10, j =20; j = i ,j?(i,j)?i :j:j; printf(“%d%d”,i,j); }what is the output?

a)20 b)20 c)10 d)10 17.main(){ extern i; printf(“%d\t”,i);

Page 63: C_C++

{ int i =20; printf(“%d\t”,i); } } what is output?

a)    “Extern valueof i “ 20 b)Externvalue of i”c)20 d)linker Error:unresolved external symbol i

18.int DIMension(int array[]){ return sizeof(array/sizeof(int);} main(){ int arr[10]; printf(“Array dimension is %d”,DIMension(arr)); } what is output?

a)array dimension is 10 b)array dimension is 1 c) array dimension is 2 d)array dimension is 5

  19.main(){ void swap(); int x = 45, y = 15; swap(&x,&y); printf(“x = %d y=%d”x,y); } void swap(int *a, int *b){ *a^=*b, *b^=*a, *a^ = *b; what is the output?

a)    x = 15, y =45 b)x =15, y =15 c)x =45 ,y =15 d)x =45 y = 45   20.main(){ int i =257; int *iptr =&i; printf(“%d%d”,*((char*)iptr),*((char *)iptr+1)); } what is output?

a)1, 257 b)257 1 c)0 0 d)1  1   21.main(){ int i =300; char *ptr = &i; *++ptr=2; printf(“%d”,i);

Page 64: C_C++

} what is output?

a)556 b)300 c)2 d)302   22.#include main(){ char *str =”yahoo”; char *ptr =str; char least =127; while(*ptr++) least = (*ptr<LEAST)?*PTR:LEAST; printf(“%d”,least); } what is the output?

a)0 b)127 c) yahoo d)y   23.Declare an array of M pointers to functions returing pointers to functions returing pointers to characters.

a)(*ptr[M]()(char*(*)()); b)(char*(*)())(*ptr[M])() c)(char*(*)(*ptr[M]())(*ptr[M]()  d)(char*(*)(char*()))(*ptr[M])();

  24.void main(){ int I =10, j=2; int *ip = &I ,*jp =&j; int k = *ip/*jp; printf(“%d”,k); } what is the output?

a)2 b)5 c)10 d)compile error:unexpected end of file in comment started in line 4

  25.main(){ char a[4] =”GOOGLE”; printf(“%s”,a); } what is the output?

a)2 b) GOOGLE c) compile error: yoo mant initializers d) linkage error.

  50. Struct(s){int a;long b;}Union (u){

Page 65: C_C++

int a;long b;}Print sizeof(s)and sizeof(u) if sizeof(int)=4 and sizeof(long)=452. char S;char S[6]= " HELLO";printf("%s ",S[6]);output of the above program ? (0, ASCII 0, I,unpredictable)53. Unsigned char c;for ( c=0;c!=256;c++2)printf("%d",c);No. of times the loop is executed ? (127,128,256,infinitely)54. int i;i=0;repeati=i+1; <====== PASCAL PROGRAMprint i;until(i<10)endNo. of times the loop is executed?int i;i=2;i++;if(i=4){printf(i=4);}else{printf(i=3);}output of the program ? (4,3,unpredictable,none)

Page 66: C_C++

1. out put of the program void main() { int i=0;for(  ;  ;  ){ if(i<10){  print("%d",i); break; }} 5.what is the output of programvoid main(){ int i;{

int i=3; printf("%d",i);}}

1. find(int x,int y) { return ((x<y)?0:(x-y)):} call find(a,find(a,b)) use to find (a) maximum of a,b   (b) minimum of a,b (c) positive difference of a,b (d) sum of a,b  2. integer needs 2bytes , maximum value of an unsigned integer is  (a) { 2 power 16 } –1  (b) {2 power 15}-1  (c) {2 power16}  (d) {2 power 15}   3.y is of integer type then expression  3*(y-8)/9 and (y-8)/9*3 yields same value if  (a)must yields same value  (b)must yields different value  (c)may or may not yields same value  (d) none of the above  4. 5-2-3*5-2 will give 18 if  (a)- is left associative,* has precedence over - (b) - is right associative,* has precedence over -  (c) - is right associative,- has precedence over * (d)- is left associative,- has precedence over *  5. printf("%f", 9/5); prints  (a) 1.8,  (b) 1.0,  (c) 2.0,  (d) none  6. if (a=7) printf(" a is 7 ");

Page 67: C_C++

 else  printf("a is not 7"); prints  (a) a is 7,  (b) a is not 7,  (c) nothing,  (d) garbage.  7. if (a>b) if(b>c) s1; else s2; s2 will be executed if  (a) a<= b,  (b) b>c, (c) b<=c and a<=b,  (d) a>b and b<=c. 8. main() {  inc(); ,inc(); , inc();  } inc() { static int x; printf("%d", ++x); } prints (a) 012,  (b) 123, (c) 3 consecutive unprectiable numbers  (d) 111.  9.preprocessing is done  (a) either before or at begining of compilation process (b) after compilation before execution (c) after loading (d) none of the above.  10. printf("%d", sizeof("")); prints  (a) error  (b)0  (c) garbage  (d) 1.  11.main() {  int a=5,b=2; printf("%d", a+++b); }  (a) results in syntax,  (b) print 7,  (c) print 8,  (d) none,  12. process by which one bit patten in to another by bit wise operation is  (a) masking,  (b) pruning,  (c) biting,  (d) chopping,

13.value of automatic variable that is declared but not intialized will be  (a) 0,  (b) -1,  (c) unpredictable, (d) none,  14. int v=3, *pv=&v;

Page 68: C_C++

 printf(" %d %d ", v,*pv); output will be  (a) error  (b) 3 address of v,  (c) 3 3  (d) none.  15. declaration enum cities{bethlehem,jericho,nazareth=1,jerusalem} assian value 1 to (a) Bethlehem   (b) nazareth  (c)bethlehem & Nazareth  (d)jericho & nazareth  16. #include<conion.h> #include<stdio.h> void main() { char buffer[82]={80}; char *result; printf( "input line of text, followed by carriage return :\n"); result = cgets(buffer); printf("text=%s\n",result); } (a) printf("length=%d",buffer[1]);   (b) printf("length=%d",buffer[0]); (c) printf("length=%d",buffer[81]);  (d) printf("length=%d",buffer[2]); 17. consider scanf and sscanf function , which is true  (a) no standard function called sscanf (b) sscanf(s,...) is equivalent to scanf(...) except that input charecter are taken from string s. (c) sscanf is equivalent to scanf. (d) none of above.  18. #include <stdio.h> main() { char line[80]; scanf("%[^\n]",line); printf("%s",line); } what scanf do ? (a) compilation error . illegal format string. (b) terminates reading input into variable line. (c) and (d) other two options.  

 20 . ceil(-2.8) ? (a) 0  (b) -3.0  (c) -2.0  (d) 2  21. for( p=head; p!=null; p= p -> next) free(p); 

Page 69: C_C++

 (a) program run smooth.  (b) compilation error. (c) run time error.  (d) none of above.  22. int x[3][4] ={ {1,2,3}, {4,5,6}, {7,8,9} } (a) x[2][1] = x[2][2] =x[2][3] = 0  (b) value in fourth column is zero  (c) value in last row is zero  (d) none of above.

 23. main () {  printf("%u" , main()); } (a) print garbage. (b) execution error (c) printing of starting address of function main. (d) infinite loop.  24 . int a, *b = &a, **c =&b; .... .... ..... a=4; ** c= 5; (a) doesnot change value of a  (b) assign address of c to a. (c) assign value of b to a.  (d) assign 5 to a.

6.What is the output of thefollowing program?#include<stdio.h>Main(){int a,b,c;A=b=c=-1;++a&&++b||++c;++a||++b&&++c;Printf(“%d%d%d\n”,a,b,c);}

A.1 -1 -1 B.1 0 1 C.1 -1 0 D.1 -1 1

6.If the following program “myprog” is run from the command line as Myprog Friday Saturday Sunday What is the output ??

#include<stdio.h>Main(int argc,char*argv[]){printf(“%c”,**++argv);}

Page 70: C_C++

A. m B. F C. Friday D. myprog

8.Consider the following definition of a queue_recordStruct queue_record{ unsigned in max_size,q_front,q_rear,q_size;Element_type*queue_array;}Which of the following values of q_size,q_front and q_rear(respectively) givesRepresentation of an empty queue

A.0,0,0 B.0,0,1 C.0,1,0 D.0,1,1

9.What is the type of x in the declaration char (*(*x[3]())[5]

A. array[5] of pointer to function returning pointer to array[3] of charB. array[5] of pointer to function returning array[3] of pointer to charC. array[3] of pointer to function returning pointer to array[5] of charD. array[3] of pointer to function returning array[5] of pointer to char

10.Consider the following recursive definition of the function fib

Int fib(int n){If(n<=0) return 1;Else return(fib(n-1)+fib(n-2))}To compute the fib(n),how many times is the function fib is invoked?

A. fib(n) B.1+ fib(n) C. fib(n+) D. none

11.if xis an unsigned integer ,the value of (x<<1)>>1 is

A. always equal to x B. never equal to xC. less than or equal to x D. greater than or equal to x

Page 71: C_C++

12.If the following code segmentFor(j=0;j<MAX;j++)A[i][j]=0.0For(i=0;i<MAX;i++)A[i][j]=1.0Is replaced by:For(i=0;i<MAX;i++){ For(j=0;j<MAX;j++)A[i][j]=0.0A[i][j]=1.0}

A. locality of reference may be better, improving cache behaviorB. locality of reference may be better may slow down the executionC. both a and b are trueD. none

8. #include<stdio.h>#include<string.h>Void main(){INT N=0;For(i=12,i>0;i--){N+=i*i;If(i==2) break;}Printf(“%d”,n);}

11) #include<stdio.h>#include<string.h>Void main(){Char s[]=”hello’;Char*t= strok(s,Intergraph);While(t){Print(“%s”,t);T=strok(NULL,”Intergraph”);}}

Page 72: C_C++

What is the output of the following program?

Void main(){

int a [] = {1,2,3,4,5};int i;for (i=0;i<5;i++)*(a+i)=f ( a+i)for( i=0;i<5;i++)printf( “%d”, [i]a);

}int f ( int a[] ){

Return (*a) ++ || 0+1;}

(a) 1111 (b) 22222 (c) 222 (d) 13513 (e) 24135

Question 5What is the output of the following perl code?

#!/usr/bin/perlSub have_fun {

My $start = shift;Return sub { $start++ }

}My $from_ten = have_fun (10);My $form_five = hava_fun (5);Print $from_five - > ();Print $from_five - > ();

(a) 5 5 (b) 4 6 (c) 5 6 (d) 6 5 (e) 5 10  2) What is the output of the following program ? main () { unsigned int i; for (i = 10; i >= 0; i--) printf ("%d", i); }

a) prints numbers 10 - 0b) prints nos 10 - 1

c) d) goes into infinite loop

Page 73: C_C++

17) How many x's are printed? for (i = 0, j = 10; i < j; i++, j--) printf ("x"); a) 10 b) 5 c) 4 d) none18) output? main () { int i = 2, j = 3, k = 1; swap (i, j) printf ("%d %d", i, j); } swap (int i, int j) { int temp; temp = i; i = j; j = temp; } YOU KNOW THE ANSWER19) main () { int i = 2; twice (2); printf ("%d", i); } twice (int i) { bullshit }  int i, b[] = {1, 2, 3, 4, 5}, *p; p = b; ++*p; p += 2;32) main () { char *name = "name"; change (name); printf ("%s", name); } change (char *name) { char *nm = "newname"; name = nm; } What is the output? a) name b) newname c) name = nm not valid d) function call invalid 

Page 74: C_C++

33) char name[] = {'n', 'a', 'm', 'e'} printf ("name = \n%s", name); a) name = name b) name = followed by funk characters c) name = \n name d) none  34) int a = 0, b = 2;

if (a = 0) b = 0;

else b *= 10; What is the value of b? a) 0 b) 20 c) 2 d) none  35) int x = 2, y = 2, z = 1; what is the value of x afterh the following statmements? if (x = y%2) z = crap else crap  a) 0 b) 2 c) 1 d) none  37) output? initially n = -24; printf (int n) { if (n < 0) {

printf ("-"); n = -n;

} if (n % 10)

printf ("%d", n); else

printf ("%d", n/10);  printf ("%d", n); }  a) -24 b) 24 c) d) -224  38) float x, y, z; scanf ("%f %f", &x, &y);  if input stream contains "4.2 3 2.3 ..." what will x and y contain after scanf? a) 4.2, 3.0 b) 4.2, 2.3 c) d) 

Page 75: C_C++

39) #define max(a,b) (a>b?b:a) #define squre(x) x*x int i = 2, j = 3, k = 1; printf ("%d %d", max(i,j), square(k));  output? a) 32 b) 23 c) 31 d) 13  40) struct adr { char *name; char *city; int zip; }; struct adr *adradr; which are valid references?  i) adr->name X ii) adradr->name iii) adr.zip X iv) adradr.zip  41) main (x, y) int x, char *y[]; { printf ("%d %s", x, y[1]); } output ? when invoked as prog arg1? a. 1 prog b. 1 arg1 c. 2 prog d. 2 arg1  42) extern int s; int t; static int u; main () { }  which of s, t and u are available to a function present in another file a. only s b. s & t c. s, t, u d. none

Page 76: C_C++

 43) main () { } int a; f1(){} f2(){}  which of the functions is int a available for? a. all of them b. only f2 c. only f1 d. f1 and f2 only int a = 'a', d = 'd'; char b = "b", c = "cr";  main () { mixup (a, b, &c); } mix-up (int p1, char *p2, char **p3) { int *temp; ....doesn’t matter..... }  44) What is the value of a after mix-up? a) a b) b c) c d) none  45) What is the value of b after mix-up? a) a b) b c) c d) none  46) main () { char s[] = "T.C.S", *A; print(s); } print (char *p) { while (*p != '\0') {

if (*p != ".") printf ("%s", *p); p++;

} } output? a) T.C.S b) TCS c) d) none  47) A question on do ... while  48) A question on % operator 

Page 77: C_C++

49) main () { int ones, twos, threes, others; int c; ones = twos = threes = others = 0; while ((c = getchar ()) != EOF)

{ switch (c) { case '1': ++ones; case '2': ++twos; case '3': ++threes;

break; default: ++others;

break; }

} printf ("%d %d", ones, others);

} if the input is "1a1b1c" what is the output? a) 13 b) c) 33 d) 31

11) What is the value of the following expression? i = 1; i << 1 % 2 a) 2 b) c) 1 d) 0

12) What is the value of the following expression? i = 1; i = (i <<= 1 % 2) a) 2 b) c) 0 d) erroneous syntax

What is the result?13) *A + 1 - *A + 3 a) - b) -2 c) 4 d) none of the above

14) &A[5] - &A[1]? a) b) c) 4 d)

15) C allows a) only call by value b) only call by reference c) both d) only call by value and sometimes call by reference

Page 78: C_C++

16) The following statement is " The size of a struct is always equal to the sum

of the sizes of its members" a) valid b) invalid c) can't say23) x = fopen (b, c) what is b? a) pointer to a character array which contains the filename b) filename whithin double quotes c) can be anyone of the above d) none

24) x = malloc (y). Which of the following statements is correct. a) x is the size of the memory allocated b) y points to the memory allocated c) x points to the memory allocated d) none of the above25) which is the valid declaration? a) #typedef struct { int i;}in; b) typedef struct in {int i;}; c) #typedef struct int {int i;}; d) typedef struct {int i;} in;26) union { int no; char ch; } u; What is the output? u.ch = '2'; u.no = 0; printf ("%d", u.ch); a) 2 b) 0 c) null character d) none

27) Which of these are valid declarations? i) union { ii) union u_tag {

int i; int i; int j; int j;

}; };

iii) union { iv) union { int i; int i; int j; int j; FILE k; }u;

};

a) all correct b) i, ii, iv c) ii & iv d)

28) p and q are pointers to the same type of dataitems. Which of these are valid? i) *(p+q) ii) *(p-q)

Page 79: C_C++

iii) *p - *q

a) all b) c) iii is valid sometimes

29) which are valid? i) pointers can be added ii) pointers can be subtracted iii) integers can be added to pointers a) all correct b) only i and ii

30) int *i; float *f; char *c; which are the valid castings? i) (int *) &c ii) (float *) &c iii) (char *) &i

31) int i = 20; printf ("%x", i); what is the output? a) x14 b) 14 c) 20 d) none of the above

32) main () { char *name = "name"; change (name); printf ("%s", name); } change (char *name) { char *nm = "newname"; name = nm; } what is the output? a) name b) newname c) name = nm not valid d) function call invalid

33) char name[] = {'n', 'a', 'm', 'e'} printf ("name = \n%s", name); a) name = name b) name = followed by funk characters c) name = \nname d) none

34) int a = 0, b = 2;

Page 80: C_C++

if (a = 0) b = 0;

else b *= 10; what is the value of b? a) 0 b) 20 c) 2 d) none

35) int x = 2, y = 2, z = 1; what is the value of x afterh the following statmements? if (x = y%2) z = crap else crap

a) 0 b) 2 c)1 d)none

37) output? initially n = -24; printd (int n) { if (n < 0) {

printf ("-"); n = -n;

} if (n % 10)

printf ("%d", n); else

printf ("%d", n/10);

printf ("%d", n); } a. -24 b.24 c. d.-224

38) float x, y, z; scanf ("%f %f", &x, &y);

if input stream contains "4.2 3 2.3 ..." what will x and y contain after scanf? a. 4.2, 3.0 b. 4.2, 2.3 c. d.

39) #define max(a,b) (a>b?b:a) #define squre(x) x*x

int i = 2, j = 3, k = 1; printf ("%d %d", max(i,j), squre(k));

Page 81: C_C++

output? a.32 b.23 c.31 d.1340) struct adr { char *name; char *city; int zip; }; struct adr *adradr; which are valid references?

i) adr->name X ii) adradr->name iii) adr.zip X iv) adradr.zip41) main (x, y) int x, char *y[]; { printf ("%d %s", x, y[1]); } output when invoked as prog arg1 a. 1 prog b. 1 arg1 c. 2 prog d. 2 arg1

42) extern int s; int t; static int u; main () { } which of s, t and u are availeble to a function present in another file a. only s b. s & t c. s, t, u d. none

43) main () { } int a; f1(){} f2(){}

which of the functions is int a available for? a. all of them b. only f2 c. only f1 d. f1 and f2 only

Page 82: C_C++

int a = 'a', d = 'd'; char b = "b", c = "cr";

main () { mixup (a, b, &c); } mixup (int p1, char *p2, char **p3) { int *temp; ....doesnt matter..... }

44) what is the value of a after mixup? a. a b.b c.c d.none of the above

45) what is the value of b after mixup? a. a b.b c.c d.none of the above

46) main () { char s[] = "T.C.S", *A; print(s); } print (char *p) { while (*p != '\0') {

if (*p != ".") printf ("%s", *p); p++;

} } output? a.T.C.S b.TCS c. d. none of the above

47) a question on do ... while48) a question on % operator

Q2) This question is based on the complexity ...

Q3) s->AB A->a B->bbA

Which one is false for above grammar.

Page 83: C_C++

Q3)Some Tree were given & the question is to fine preorder traversal.

Q4)One c++ program, to find output of the program..

Answer the questions based on the following programVOID FUNCTION(INT KK){KK+=20;}VOID FUNCTION (INT K){INT MM,N=&MKN = KKN+-=10;}

Q. What is the output of the following programmain(){ int var=25,varp;varp=&var;varp p = 10;fnc(varp)printf("%d%d,var,varp);}

(a) 20,55 (b) 35,35 (c) 25,25 (d)55,55 Section D1. a=2, b=3, c=6     Find the value of c/(a+b)-(a+b)/c

4. Q is not equal to zero and k = (Q x n - s)/2.What is  n?(a) (2 x k + s)/Q (b) (2 x s x k)/Q (c) (2 x k - s)/Q(d) (2 x k + s x Q)/Q (e) (k + s)/Q1]. The following variable is available in file1.c

static int average_float;

all the functions in the file1.c can access the variable

[2]. extern int x;

Check the answer

Page 84: C_C++

[3]. Another Problem with

# define TRUE 0

some code

while(TRUE) { some code } This won't go into the loop as TRUE is defined as 0

[4]. A question in structures where the memebers are dd,mm,yy.

mm:dd:yy 09:07:97

[5]. Another structure question

1 Rajiv System Analyst

[6]. INFILE.DAT is copied to OUTFILE.DAT

[7]. A question with argc and argv .

Input will be

c:\TEMP.EXE Ramco Systems India

1. convert 0.9375 to binary (c)a) 0.0111 b)0.1011 c)0.1111 d)none

 2.( 1a00 * 10b )/ 1010 = 100 (b)

a) a=0,b=0 b)a=0, b=1 c) d)none 3. in 32 bit memory machine 24 bits for mantissa and 8 bits for exponent. to increase the range of floating point.a) more than 32 bit is to be there.b) increase 1 bit for mantissa and decrease 1 bit for exponentc) increase 1 bit for exponent and decrease one bit for mantissad)5. in C "X ? Y : Z " is equal toa) if (X==0) Y ;else Zb) if (X!=0) Y ;else Zc) if (X==0) Y ; Zd) 6. foo()int foo(int a, int b){

Page 85: C_C++

if (a&b) return 1;return 0;}

a) if either a or b are zero returns always 0b) if both a & b are non zero returns always 1c) if both a and b are negarive.......d) 7. typedef struct nt{--------} node-typenode-type *pa) p =( nodetype *)malloc( size of (node-type))b)c)d) 8. function gives some error what changes as to be madevoid ( int a,int b){int t; t=a; a=b; b=t;}a)define void as int and write return ttb)change everywhere a to *a and b to *bc) d) 

9. which of the following is incorrecta) if a and b are defined as int arrays then (a==b) can never be trueb) parameters are passed to functions only by valuesc) defining functions in nested loops

The questions asked in the first technical interview are

1. Tell me abt urself2. Write a programme for binary seaching3. What is a semaphore and where do we use them4. What is meant by LRU(least recently used)5. A puzzle6. About ur family7. About ur higher studies and plans for the future8. Why adp 9. What is the diff between structures and unions10. How we declare the variables in an union and so on...........

1) Which of these is an invalid dataname?a) wd-count  b) wd_count c) w4count d) wdcountabcd

11) What is the value of the following expression? i = 1; i << 1 % 2 a) 2 b) c) 1 d) 0

Page 86: C_C++

12) What is the value of the following expression? i = 1; i = (i <<= 1 % 2)      a) 2 b) c) 0 d) erroneous syntaxWhat is the result?13) *A + 1 - *A + 3  a) - b) –2 c) 4 d) none of the above 4) &A[5] - &A[1]?  a) b) c) 4 d)  15) C allows a) only call by value b) only call by reference c) both d) only call by value and sometimes call by reference  16) The following statement is " The size of a struct is always equal to the sum of the sizes of its members" a) valid b) invalid c) can't say

20) What is the value of *p; a) 2 b) 3 c) 4 d) 521) What is the value of (p - (&p - 2))? a) b) 2 c) d) 23) x = fopen (b, c) what is b? a) pointer to a character array which contains the filename b) filename within double quotes c) can be anyone of the above d) none24) x = malloc (y). Which of the following statements is correct.

a) x is the size of the memory allocated. b) y points to the memory allocated c) x points to the memory allocated d) none of the above25) Which is the valid declaration? a) #typedef struct { int i;}in; b) typedef struct in {int i;}; c) #typedef struct int {int i;}; d) typedef struct {int i;} in;

26) Union { int no; char ch; } u;  What is the output? u.ch = '2'; u.no = 0; printf ("%d", u.ch);  a) 2 b) 0 c) null character  d) none27) Which of these are valid declarations? i) union { ii) union u_tag {

int i; int i;

Page 87: C_C++

int j; int j; }; };     iii) union { iv) union {

int i; int i; int j; int j; FILE k; }u;

};     a) all correct b) i, ii, iv c) ii & iv d)28) p and q are pointers to the same type of dataitems. Which of these are valid? i) *(p+q) ii) *(p-q) iii) *p - *q a) all b) c) iii is valid sometimes29) which are valid? i) pointers can be added ii) pointers can be subtracted iii) integers can be added to pointers  a) all correct  b) only i and ii30) int *i; float *f; char *c;  which are the valid castings? i) (int *) &c ii) (float *) &c iii) (char *) &i31) int i = 20; printf ("%x", i);  What is the output?

a)  x14 b) 14 c) 20 d) none  01.consider the following piece of code 01 GROSS-PAY 05 BASIC-PAY PIC 9(5) 05 ALLOWENCES PIC 9(3) if BASIC-PAY has a value 1000 and ALLOWENCES has a value of 250,what will be displayed by the statement DISPLAY GROSS-PAY a.1250 b.01000250 c.01250 d.1.25002.consider two data items 77 W-A PIC 9(3)V99 VALUE 23.75 77 W-B PIC ZZ9V99 VLAUE 123.45 after the statement MOVE W-A TO W-B what will be W-B's value? a.123.75 b.b23.75 (where b indicates space) c.023.75

Page 88: C_C++

d.invalid move03.what is the result of the following? DIVIDE A INTO B GIVING C.    a.C=A/B b.the reminder of B/A is stored in C c.C=B/A d.the reminder of A/B is stored in C

Page 89: C_C++

04.consider the statement (incomplete) IF(A NUMERIC) DISPLAY A the variable A can be a.NUMERIC b.ALPHABETIC c.ALPHANUMERIC d.NUMERIC OR ALPHANUMERIC05.which of the following can be used as a check protection symbol a.Z b.S c.* d.+06.what if any ,is the syntex error in the following piece of code 01 B PIC A(7) 02 C PIC 9(4) ........ IF(B NUMERIC) ADD 10 TO C a.the condition in the if statement is wrong b.noting is wrong c.because C is initialised.ADD 10 TO C is wrong d.both B and C shoud have same size.

07.study the following code 01 A1 05 B PIC 99 05 C PIC X(4) 01 A2 05 B PIC 99V99 05 C PIC A(4) pick out the valid statement from the following a.A1 and A2 can not have sub-ordinates b.A1 and A2 can have the same sub-ordinates but must have same PIC clause c.there is nothing wrong d.A1 and A2 can have same sub-ordinates provided they are not at 01 level08.study the following 01 A PIC 99V0 VALUE 5 01 B PIC 9V9 VALUE 6 01 C PIC 99V9 VALUE 2.5 01 D PIC 99 VALUE 3 COMPUTE A ROUNDED B C = A+B*C/D ON SIZE ERROR PERFORM PRINT-ERROR the comments of A.B.C after execution of the above statement are a.A=10 B=0 C=10 b.A=10 B=9.9 C=9.9 c.A=10 B=0 C=9.9 d.A=10 B=6 C=1009.how many times PARA-A is performed : PERFORM PARA-A VARYING TIMES-COUNTER FROM 1 BY 1

Page 90: C_C++

UNTIL TIMES-COUNTER >0 PARA-A MOVE P TO Q MOVE H TO TIMES COUNTER a.10 b.1 c.11 d.010.consider the following piece of code 01 GROUP-ITEM 05 AMOUNT-1 PIC 99V9 USAGE COMP VALUE 50 05 AMOUNT-2 PIC 9(4)V99 USAGE COMP MOVE ZERO TO GROUP-ITEM ADD 50 TO AMOUNT-1 what will be the content of AMOUNT-1? a.50 b.100 c.0 d.unpredictable11.consider the following progrm statements MOVE 0 TO SW.NO.OF.REC PERFORM PRI-OUT UNTIL SW=1 DISPALY NO.OF.REC STOP RUN PRE-OUT READ IN-FILE AT END MOVE 1 TO SW WRITE OUO-REC FROM IN-REC ADD 1 TO NO.OF REC if the IN-FILE contains 1000 records what value will be displayedafter the PERFORM is over?assume that N0.OF.REC has PIC 9(4) a.1000 b.1001 c.1 d.none of the above since there is a syntex error12.study the data discriptions and answer the questions given below i)01 ORDER RECORD 05 OUT-HEADER PIC X(50) 05 ITEM-COUNT PIC 99 05 OUT-ITEM PIC X(20) OCCURS 1 TO 20 DEPENDING ON ITEM-COUNT ii)01 NAME-AND-ADDRESS 05 N-AND-A-LINE OCCURES 5 05 LINE-LENGTH PIC P9 05 N-AND-A-CHAR PIC X OCCURS 1 TO 20 DEPENDING ON LINE-LENGTH iii)01 SALES-LIST 05 SALESMAN-COUNT PIC 99 05 SALES PIC 9(6) OCCURS 1 TO 100 DEPENDING ON SALESMAN-COUNT iv)01 ORDER-RECORD 05 NO-OF-BRANDS PIC 99

Page 91: C_C++

05 BRAND-PURCHASED OCCURS 1 TO 15 DEPENDING ON NO-OF-BRANDS which of the following is true? a.i) and iii) are valid b.i) and iv) are valid c.i) and iii) are not valid d.all are valid13.C1 C2 C3 are three conditions whose TRUTH values are as folloes. C1-TRUE C2-FALSE C3-TRUE A,B,C are defined as given below A:C1 AND(NOT C2) OR C3 B.(NOT C1) OR (NOT C2 AND NOT C3) C.(C1 OR C2)AND C3 D.C1 AND C2 OR C3 given the above information which of the following statements are valid? a.only A,B and C are TRUE b.only A,C and D are TRUE c.A,B,C and D are TRUE d.only C and D are TRUE14.consider the following FD FILE-1 01 REC-1 PIC X(80) ...... WORKING-STORAGE SECTION 01 W-REC PIC X(90) ........ PROCEDURE DIVISION FIRST-PARA ....... READ FILE-1 INTO W-REC AT END MOVE 1 TO EOF-FLAG which of the following is true with respect to the above? a.REC-1 will contain nothing and W-REC will contain the contains of the record read b.REC-1 and W-REC contain the same data c.syntex is invalid and error will occur d.REC-1 and W-REC must be of same size15.PERFORM ACCUMULATE-TOTALS VARYING A FROM 1 BY 2 UNTIL A >2 AFTER B FROM1 BY 1 UNTIL B>2 AFTER C FROM 2 BY -1 UNTIL C<2 the paragraph ACCUMULATE-TOTALS would be exicuted a.18 times b.4 times c.8 times d.24 times