logo

CuriousTab

CuriousTab

Discussion


Home C Programming Functions See What Others Are Saying!
  • Question
  • What will be the output of the program?
    #include<stdio.h>
    
    int main()
    {
        void fun(char*);
        char a[100];
        a[0] = 'A'; a[1] = 'B';
        a[2] = 'C'; a[3] = 'D';
        fun(&a[0]);
        return 0;
    }
    void fun(char *a)
    {
        a++;
        printf("%c", *a);
        a++;
        printf("%c", *a);
    }
    


  • Options
  • A. AB
  • B. BC
  • C. CD
  • D. No output

  • Correct Answer
  • BC 


  • More questions

    • 1. 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
    • 2. 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
    • 3. 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
    • 4. 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
    • 5. 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
    • 6. What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          char far *near *ptr1;
          char far *far *ptr2;
          char far *huge *ptr3;
          printf("%d, %d, %d\n", sizeof(ptr1), sizeof(ptr2), sizeof(ptr3));
          return 0;
      }
      

    • Options
    • A. 4, 4, 8
    • B. 4, 4, 4
    • C. 2, 4, 4
    • D. 2, 4, 8
    • Discuss
    • 7. Nested unions are allowed

    • Options
    • A. True
    • B. False
    • Discuss
    • 8. What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          char huge *near *far *ptr1;
          char near *far *huge *ptr2;
          char far *huge *near *ptr3;
          printf("%d, %d, %d\n", sizeof(ptr1), sizeof(*ptr2), sizeof(**ptr3));
          return 0;
      }
      

    • Options
    • A. 4, 4, 4
    • B. 2, 4, 4
    • C. 4, 4, 2
    • D. 2, 4, 8
    • Discuss
    • 9. What will be the output of the program?
      #include<stdio.h>
      typedef void v;
      typedef int i;
      
      int main()
      {
          v fun(i, i);
          fun(2, 3);
          return 0;
      }
      v fun(i a, i b)
      {
          i s=2;
          float i;
          printf("%d,", sizeof(i));
          printf(" %d", a*b*s);
      }
      

    • Options
    • A. 2, 8
    • B. 4, 8
    • C. 2, 4
    • D. 4, 12
    • Discuss
    • 10. What will be the output of the program (myprog.c) given below if it is executed from the command line?
      cmd> myprog 1 2 3
      /* myprog.c */
      #include<stdio.h>
      #include<stdlib.h>
      
      int main(int argc, char **argv)
      {
          int i, j=0;
          for(i=0; i<argc; i++)
              j = j+atoi(argv[i]);
          printf("%d\n", j);
          return 0;
      }
      

    • Options
    • A. 123
    • B. 6
    • C. Error
    • D. "123"
    • Discuss


    Comments

    There are no comments.

Enter a new Comment