Blogroll

This blog is created for education about engineering students.All the engineering students are get free downloadable books here. not only books and also different software also available here

C APTITUDE TEST

Test No: 1       Date: 19-08-2011        Max.Marks:25 M       Topic:Arrays
 
Note:   Proper required header files are included
Program is compiled using Turbo C/C++ compiler
Program run under Windows environment

Predict the output (or) errors for the following?

  1.    main( )                                                                                                             [       ]
              {
                static char arr[ ]=”University”;
                printf(“%d”, *(arr + strlen(arr)));
               }
a.       compiler error        b. linker error               c. logical error              d. 0
e.    1                           f. 2                               g. none
      2.      main( )                                                                                                             [       ]
           {
            char  arr[ ]=”hello\0\0\0\0\0”;
            char arr1[ ]=”hello\n\n\n\n\n”;
            clrscr( );
            printf(“%d\t%d\n”,sizeof(arr),strlen(arr));
            printf(“%d\t%d\n”,sizeof(arr1),strlen(arr1));
            }
a.       11  5                      b. 10    6                      c. 11    5          d. none
11  10                        11    11                        10    10
     3.      main( )                                                                                                             [      ]
            {
            char str[4]=”VITS”;
            printf(“%s”,str);
           }
a.       VITS                      b. compiler error          c. runtime error            d. none
           4. main( )                                                                                                             [      ]
{
            int arr[6]={12,13};
            printf(“\n%d %d %d”,a[2],a[3],a[4]);
}
a.       Garbage values      b. 0      c. 0 0               d. 0 0 0            e. none

5.      main( )                                                                                                             [      ]
{
            printf(“%d  %d”,sizeof(‘A’),sizeof(“A”));
}
a.       2  2            b. 1  1              c. 1  2              d. none

6.      main( )                                                                                                             [      ]
{
            printf(“Hello Readers!” + 6);
}
a.       compiler error        b. linker error               c. Hello Readers!         d. Readers!


7.      main( )                                                                                                             [      ]
{
            putchar(“Hello Readers!”[6]);
            putchar(6[“Hello Readers!”]);
}
a.       RR             b. oo                c. Twice white space character            d. none
8.      main( )                                                                                                             [      ]
{
            char str1[ ]=”Strings!”;
            char str2[ ]=”Strings!”;
            if(str1= = str2)
            {
                        printf(“Strings are same”);
            }
            else
            {
                        printf(“Strings are different”);
            }
}
a.       Strings are same     b. compiler error          c. Strings are different d.   none
9.      The ASCII code of the null character is                                                                       [      ]
a.       32              b. 27                c. 13                d. none
10.  main( )                                                                                                             [      ]
{
            int arr[ ]={1,2,3};
            arr[ 0,1,2]=10;
            printf(“%d %d %d”,arr[0],arr[1],arr[2]);
}
a.       compiler error   b.  runtime error                c. 1 2 3                        d. 1 2 10
11.  main( )                                                                                                             [      ]
{
            int arr[ 3] ={1,2,3};
            printf(“%d %d %d”,arr[1],arr[2],arr[3]);
}
a.       1 2 3          b. compiler error          c. 1 2 0                                    d. 1 2 garbage value
e.    2 3 garbage value
       
12. main( )                                                                                                             [      ]
            {
                        int i;
int arr[ ]={1,2,3,4,5};
                        arr[ 1+2 ]=10;
                        for(i=0;i<5;i++)
                        {
                                    printf(“%d ”,arr[ i ]);
                        }
            }
a.       1 2 3 4 5                b. compiler error          c. 1 2 3 10 5                d. none
13.  main( )                                                                                                             [      ]
{
            int arr[6]={1,2,3,4};
            int i;
            for(i=0;i<6;i++)
            {
                        printf(“%d “,arr[i]);
            }
}
a.       1 2 3 4       b. 1 2 3 4 garbage values         c. compiler error          d. none

14.  main( )                                                                                                             [      ]
{
            int a[ ]={1,2,3,4,5};
            printf(“%d %d %d %d %d”,*a,*(a+0),*(0+a),a[0],0[a]);
}
a.       1 2 3 4 5                b. compiler error          c. 1 1 1 1 1      d. none
15.  main( )                                                                                                             [      ]
{
            int a[2][3]={1,2,3,4};
            printf(“%d %d %d %d %d %d “,a[0][0],a[0][1],a[0][2],a[1][0],a[1][1],a[1][2]);
}
a.1 2 3 4 garbage values          b. 1 2 3 4 -1 -1             c. 1 2 3 4 0 0   d. 1 2 0 3 4 0
e. none
16.   main( )                                                                                                                        [      ]
{
            int a[2][3]={1,2}{3,4};
            printf(“%d %d %d %d %d %d “,a[0][0],a[0][1],a[0][2],a[1][0],a[1][1],a[1][2]);
}
a.1 2 3 4 garbage values          b. 1 2 3 4 -1 -1             c. 1 2 3 4 0 0   d. 1 2 0 3 4 0
e. none
17.   main( )                                                                                                                        [      ]
{
            int a[ ][ ]={1,2,3,4};
            printf(“%d %d %d %d %d %d “,a[0][0],a[0][1],a[0][2],a[1][0],a[1][1],a[1][2]);
}
a.1 2 3 4 garbage values          b. 1 2 3 4 -1 -1             c. 1 2 3 4 0 0   d.1 2 0 3 4 0
e. compiler error                      f. none
18.   main( )                                                                                                                        [     ]
{
            int a[ ][3]={1,2,3,4};
            printf(“%d %d %d %d %d %d “,a[0][0],a[0][1],a[0][2],a[1][0],a[1][1],a[1][2]);
}
a.1 2 3 4 garbage values          b. 1 2 3 4 -1 -1             c. 1 2 3 4 0 0   d. 1 2 0 3 4 0
e. compiler error                      f. none
     
 19. In C language, elements of two-dimensional arrays are stored on                                [      ]
            a. Random order          b. Row major order      c. Column major order
            d. none
       
20. In FORTRAN language, elements of two-dimensional arrays are stored on     [      ]
            a. Random order          b. Row major order      c. Column major order
            d. none

      
 21. Write a program in C for swapping of two numbers in a single statement [ i.e Method ] with out            Using a comma operator 


Key for above Questions:-

1.D   2.A    3.B   4.D    5.C    6.D    7.A    8.C    9.D   10.D
11.E  12.C  13.D  14.C  15.C  16.D  17.E  18.C  19.B  20.C 
21. Method: a = (a + b) – (b = a)   (or)      b = (a – b) + (a = b)

No comments:

Post a Comment

Total Pageviews