logo

CuriousTab

CuriousTab

Discussion


Home C Programming Arrays See What Others Are Saying!
  • Question
  • What will be the output of the program?
    #include<stdio.h>
    
    int main()
    {
        static int a[2][2] = {1, 2, 3, 4};
        int i, j;
        static int *p[] = {(int*)a, (int*)a+1, (int*)a+2};
        for(i=0; i<2; i++)
        {
            for(j=0; j<2; j++)
            {
                printf("%d, %d, %d, %d\n", *(*(p+i)+j), *(*(j+p)+i), 
                                        *(*(i+p)+j), *(*(p+j)+i));
            }
        }
        return 0;
    }
    


  • Options
  • A. 1, 1, 1, 1
    2, 3, 2, 3
    3, 2, 3, 2
    4, 4, 4, 4
  • B. 1, 2, 1, 2
    2, 3, 2, 3
    3, 4, 3, 4
    4, 2, 4, 2
  • C. 1, 1, 1, 1
    2, 2, 2, 2
    2, 2, 2, 2
    3, 3, 3, 3
  • D. 1, 2, 3, 4
    2, 3, 4, 1
    3, 4, 1, 2
    4, 1, 2, 3

  • Correct Answer
  • 1, 1, 1, 1
    2, 2, 2, 2
    2, 2, 2, 2
    3, 3, 3, 3 


  • More questions

    • 1. What are the types of linkages?

    • Options
    • A. Internal and External
    • B. External, Internal and None
    • C. External and None
    • D. Internal
    • Discuss
    • 2. Out of fgets() and gets() which function is safe to use?

    • Options
    • A. gets()
    • B. fgets()
    • Discuss
    • 3. A structure can be nested inside another structure.

    • Options
    • A. True
    • B. False
    • Discuss
    • 4. What will be the output of the program (sample.c) given below if it is executed from the command line?
      cmd> sample one two three
      /* sample.c */
      #include<stdio.h>
      
      int main(int argc, char *argv[])
      {
          int i=0;
          i+=strlen(argv[1]);
          while(i>0)
          {
              printf("%c", argv[1][--i]);
          }
          return 0;
      }
      

    • Options
    • A. three two one
    • B. owt
    • C. eno
    • D. eerht
    • Discuss
    • 5. Which of the following statement is True?

    • Options
    • A. User has to explicitly define the numeric value of enumerations
    • B. User has a control over the size of enumeration variables.
    • C. Enumeration can have an effect local to the block, if desired
    • D. Enumerations have a global effect throughout the file.
    • Discuss
    • 6. Point out the error in the program?
      struct emp
      {
          int ecode;
          struct emp *e;
      };
      

    • Options
    • A. Error: in structure declaration
    • B. Linker Error
    • C. No Error
    • D. None of above
    • Discuss
    • 7. Point out the error in the program?
      #include<stdio.h>
      
      int main()
      {
          union a
          {
              int i;
              char ch[2];
          };
          union a z1 = {512};
          union a z2 = {0, 2};
          return 0;
      }
      

    • Options
    • A. Error: invalid union declaration
    • B. Error: in Initializing z2
    • C. No error
    • D. None of above
    • Discuss
    • 8. Point out the error in the program?
      struct emp
      {
          int ecode;
          struct emp e;
      };
      

    • Options
    • A. Error: in structure declaration
    • B. Linker Error
    • C. No Error
    • D. None of above
    • Discuss
    • 9. What will be the output of the program (sample.c) given below if it is executed from the command line?
      cmd> sample friday tuesday sunday
      /* sample.c */
      #include<stdio.h>
      
      int main(int argc, char *argv[])
      {
          printf("%c", **++argv);
          return 0;
      }
      

    • Options
    • A. s
    • B. f
    • C. sample
    • D. friday
    • Discuss
    • 10. What is the purpose of fflush() function.

    • Options
    • A. flushes all streams and specified streams.
    • B. flushes only specified stream.
    • C. flushes input/output buffer.
    • D. flushes file buffer.
    • Discuss


    Comments

    There are no comments.

Enter a new Comment