Home Company Questions Caritor Interview Questions Caritor Interview Questions - 3

Login Form




Caritor Interview Questions - 3 Print E-mail

 

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

 

2. what is the output of the following code?
              #include<stdio.h>
               oid main()
                {
                 printf("%d",printf(" hello world "));
                 }

a) 13        b) hello world 13    c) hello world        d) error

Ans: b

 

3. Is const int *p same as int const* p

 

4. #include<stdio.h>
             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

 

5.     #include<stdio.h>
             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

 

6. 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<argc;I++)
             j=j+atoi(argv[i]);
             printf(%d.j);
             }

a) 123        b) 6    c) error      d) 123

Ans: 6

 

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

 

8. Are null statements in c null pointers.

 

9. what is the output of the following code, assuming that the array begins at location 5364875?
          #include<stdio.h>
          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

 

10. int i=10;

a) declaration             b) definition             c) both             d) none

Ans: c

 

11. #include<stdio.h>
               void main(int arg c)
                {
                      char a[]=abcdefghijklmnopqrstuvwxyz;
                      printf(%d,sizeof(a));
                   }

a)25        b)26          c)27         d)28

Ans: c

 

12. when pointers declared initialized to :

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

Ans: c