Caritor  Placement Paper   Aptitude - General   Not Specified-28 Nov 2005

Caritor  Placement Paper   Aptitude - General   Not Specified-28 Nov 2005


  • Posted by  FreshersWorld 
    7 Jan, 2012

     

    Technical C Test

    1.  
    Struct x
             {
              int i;
             char c;
             }
             union y{
             struct x a;                                                                                                       
             double d;
             };
            printf("%d",sizeof(union y));
             a)8 
             b)5
             c)4
            d)1
            ans:8


    2.      struct x{
                char c1;
                char c2;
                int i;
               short int j;
                   };
               struct y{
                   short int j;
                   char c1;
                   char c2;
                   int i;
                  };
              printf("%d %d",size of (struct x),size of (struct y));
               a)12 12
               b)8 8 
               c)12 8
               d)8 12                                                                                                                
               ans:a


    3.     enum x {a=1,b,c,d,f=60,y}
            printf("%d",y);
            a)5
            b)61
            c)6
            d)60
            ans:b


    4     #include
             void main(){
                  {
                  # define x 10
                 }
              printf("%d \n",++x);
                    }
              a)11
              b)10
              c)compile error 
              d)runtime error
              ans:c


    5.        #include
               void main()
                 {
                  int k=2,j=3,p=0;
                  p=(k,j,k);
                  printf("%d\n",p);
                }
                 a)  2
                 b)  error
                 c)  0                                                                                                                          
                  d) 3
               ans:a


    6.    How to typedef a function pointer which takes int as a parameter and return an int
              a)  Is not possible
              b)  typedef int *funcptr int;
              c)  typedef int * funcptr( int);
              d)  typedef int (*funcptr)(int);
              ans:d 


    7.       #include
              void main()
                {
                  int k=10;
                  k<<=1;
                  printf("%d\n",k);
               }
                  a)10
                  b)0
                  c)20
                  d)compilation error 
                  ans:c


    8.       #include
              void main()
                 {
                   int i=-10;
                   for(;i;printf("%d\n",i++));
                }
                a)error
                b)prints -10 to -1
                c)infinite loop
                d)does not print anything
               ans:b


    9.        #include                                                                                             
               void main()
                 {
                  int I=65,j=0;
                  for(;j<26; i++,j++){
                  printf("%s\n", i);
                }
             }
                 a)compilation Error
                 b)prints A to Z
                 c)prints a to z
                 d)runtime error
                 ans:b


    10. #include
          void main()
             {
                   unsigned int i=-1;
                   printf("%d\n",i);
                   printf("%u\n",i*-1);
            }
               a)runtime error
               b)compilation error
               c)prints -1 to 1
               d)prints 1 and 1
               ans:c


    11.     #include
              void main()
               {
                  int **I;
                  int *j=0;
                  i=&j;
                 if (NULL != i&& NULL != *i){
                  printf("I am here");
                }
              }
                a)prints I am here
                b)does not print anything
                c)compilaton error
                d)runtime error
                ans:b


    12        #include
                void main()
                 {
                   int *j=(int *)0x1000;
                   printf("%p",j);
               }
                     a)prints-1000
                     b)runtime error
                    c)compilation error
                    d)none of the above
                    ans:d


    13          #include
                  void main()
                    {
                       int a[2][2]={{2},{3}};
                      printf("%d",a[0][0]);
                      printf("%d",a[0][1]);
                      printf("%d",a[1][0]);
                      printf("%d",a[1][1]);
                }
                   a) 2300
                   b)2000
                  c)0030                                                                                                       
                  d)2030
                   ans:d


    14)          #include
                   void main(int x)
                    {
                      printf("%d",x) ;
                     }
                 if the name of the executable file is abc and the command line is given as abc xyz what is the 
               output
                  a)compilation error
                  b)1
                  c)2

                  d)undefined
                  ans:2


    15.        #include
                void main(int argc)
                   {
                    char a[]={'1','2','3',0,'1','2','3'};
                    printf(a);
                     }
                   a) compilation error, b) 123, c) 123 123, d) 1230123                
                    ANS:b

    16.      #include
                   void func(int *x)
                     {
                         x=(int *) malloc(sizeof(int));
                         printf("in func: %p\n",x);
                    }
                       void main(int argc)
                   {
                    int **pp;
                    int *p;
                    pp=(int **) malloc(sizeof(int *));
                    p=(int *) malloc(sizeof((int));
                   *pp=p;
                   printf("first:%p \n",*pp);
                   func(*pp);
                   printf("last %p \n",*pp);
                 }
                 assuming the p is equal to 1000 and x is equal to 2000 atfer malloc calls
                a) 1000,2000,1000,          b) 1000,2000,2000,              c) 1000,1000,1000 d) 2000,2000,2000
                 ANS:a


    17.         #include
                 #define const const
                 void main(int argc)
                   {
                      const int x=0;
                   }
                   a)  compilation error,     b)    runs fine,      c)     runtime error,    d)      none of   these
                 ANS:b


    18.       #include
                void main(int argc)
                {
                   int d=1234.5678;
                  printf("%d",d);
                }
                   a) error, b) 1234.5678, c) 1234, d) 1235
                 ANS:c


    19.       #include
                void main(int argc)
                   {
                   int a[]={5,6};
                   printf("%d",a[1.6]);
                  }
                   a) 5,          b) runtime error     , c) compilation error,      d) 6
                   ANS:d


    20.        #include
                  struct x
                    {
                     int i=0; /*line A*/
                   };
                     void main(int argc)
                      {
                       struct x y; /*line B*/
                      }
                  a) error due to B,
                  b) no problem with option A and B,
                  c) error somewhere other than line A and B,
                  d) error due to line A
                  ANS:d


    21.        #include
                 void main(int arg c)
                {
                    int x=1111;
                    printf("%d",!x);
                }
                  a.prints 1111
                  b.compilation error
                  c.prints 0
                  d.is not a valid option
                  ans:c


    22.         struct {
                  int len;
                  char *str
                     }*p;
                   ++p -> len
                   a.increments p
                   b. increments len
                   c.compilation error
                   d.nothing happens with either of p and len
                   ans:b


    23.           int i=10;
                    a.declaration
                    b.definition
                    c.both
                    d.none
                    ans:c


    24.          #include
                   void main(int arg c)
                    {
                          char a[]=abcdefghijklmnopqrstuvwxyz;
                          printf(%d,sizeof(a));
                       }
                      a.25      b.26        c.27       d.28
                   ans:c


    25.         #include
                 void main(int arg c)
                     {
                         char a[]=abcdefghijklmnopqrstuvwxyz;
                         char *p=a;
                          printf(%d,strlen(p));
                           p+=10;
                          printf(%d,strlen(a));
                   }
                  a.26 26
                  b.26 16
                  c.compilation error
                  d.16 26
                   ans:a


    26 .       If a file contains the IT solutions Inc.rn then on reading this line the array str using fgets()
                  what would str contain?
                  a. IT solutions Inc.
                  b. IT solutions Inc.r0
                  c. IT solutions Inc.rn0
                  d. IT solutions Inc.n0


    27.       if the following program (myprog)is run from the command line as myprog 1 2 3 what would 
                be the output?
                 Main(int argc , char *argv[])
                {
                  int I ,j=0;
                  for (I=0;I              j=j+atoi(argv[i]);
                 printf(%d.j);
                 }
               a. 123        b.6    c.error      d.123
                ans:6


    28.     When pointers declared initialized to : 

              a. null
              b.newly allocated memory
              c)nothing,its random
              d)none of the above
              ans:c


    29.      what is the output of the following code?
                  #include
                   oid main()
                    {
                     printf("%d",printf(" hello world "));
                     }
                     a) 13, b) hello world 13, c) hello world, d) error
                  ANS:b


    30.     what is the output of the following code, assuming that the array begins at location 5364875?
              #include
               void main()
               {
                   int a[2][3][4]={
                                            {2,1,4,3,6,5,8,7,0,9,2,2}
                                             {1,2,3,4,5,6,7,8,9,0,1,2}
                                              };
                     printf("%u %u %u %u",a,*a,**a,***a);
               }
               a) 5364875,5364876,5364877,5364878
               b) 5364875,5364876,5364877,2
               c) 5364875,5364875,5364876,5364876
               d) 5364875,5364875,5364875,2
               ANS:d


    31.    Are null statements in c null pointers.
    32.     Is cinst int *p same as int const* p

2009-2016 downloadmela.com. All rights reserved.