Test1

  1. What would be the value of i and k?
    main()
    {
         int i,j=5,k;
         i=2*j/2;
         k=2*(j/2);
    }
    5 4       4 4       4 5       5 5      
  2. What is the output of the following program?
    main()
    {
         int i=-1;
         printf(“i=%d,-i=%d”,i,-i);
    }
    i=1 -i=-1       i=-1 -i=-1       i=-1 -i=1       i=1 -i=1      
  3. What is the output of the following program?
    main()
    {
         int i=10,j=40;
         if((j-i)%10)
              printf(“True”);
         else
              printf(“False”);
    }
    True       False       Error       None      
  4. What is the output of the following program?
    main()
    {
         char ch[]={‘e’,’n’,’d’,’\0’,’p’};
         printf(“%s”,ch);
    }
    'e' 'n' 'd'       'e' 'n' 'd' '\0' 'p'       end\0p       end      
  5. What is the output of the following program?
    main()
    {
    int i;
    for(i=1;i<5;i++);
    printf(“Hello”);
    }
    print Hello 5 times       Hello       Error       None      

  6. What is the output of the following program?
    main()
    {
    int x,y=2,z,a;
    x=(y*=2)+(z=a=y);
    printf(“%d”,x);
    }
    2       4       6       8      
  7. What are the values of x,y,z after executing the following statements?
    int x=6,y=8,z;
    y=x++;
    z=++x;
    8 6 8       6 6 6       8 8 8       6 8 6      
  8. What is the output of the following program?
    main()
    {
    printf("%d",printf("Hello"));
    }
    Hello5       Hello       Error       None      
  9. What is the output of the following program?
    main()
    {
    char x=-256;
    printf(“%d”,x);
    }
    Error       -256       256       0      
  10. What is the output of the following program?
    main()
    {
    int i=4,j=20;
    if(i=5||j>50)
    printf(“Hello”);
    else
    printf(“Hi”);
    }
    Hello       Hi       Error       None      

No comments:

Post a Comment

Total Pageviews