logo

CuriousTab

CuriousTab

Discussion


Home C Programming Declarations and Initializations See What Others Are Saying!
  • Question
  • Identify which of the following are declarations

    1 : extern int x;
    2 : float square ( float x ) { ... }
    3 : double pow(double, double);


  • Options
  • A. 1
  • B. 2
  • C. 1 and 3
  • D. 3

  • Correct Answer
  • 1 and 3 

    Explanation
    extern int x; - is an external variable declaration.

    double pow(double, double); - is a function prototype declaration.

    Therefore, 1 and 3 are declarations. 2 is definition.

  • More questions

    • 1. 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
    • 2. Nested unions are allowed

    • Options
    • A. True
    • B. False
    • Discuss
    • 3. 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
    • 4. 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
    • 5. 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
    • 6. What will be the output of the program in DOS (Compiler - Turbo C)?
      #include<stdio.h>
      double i;
      
      int main()
      {
          (int)(float)(char) i;
          printf("%d", sizeof((int)(float)(char)i));
          return 0;
      }
      

    • Options
    • A. 1
    • B. 2
    • C. 4
    • D. 8
    • Discuss
    • 7. Which files will get closed through the fclose() in the following program?
      #include<stdio.h>
      
      int main()
      {
          FILE *fs, *ft, *fp;
          fp = fopen("A.C", "r");
          fs = fopen("B.C", "r");
          ft = fopen("C.C", "r");
          fclose(fp, fs, ft);
          return 0;
      }
      

    • Options
    • A. "A.C" "B.C" "C.C"
    • B. "B.C" "C.C"
    • C. "A.C"
    • D. Error in fclose()
    • Discuss
    • 8. Which of the following are unary operators in C?

      1. !
      2. sizeof
      3. ~
      4. &&

    • Options
    • A. 1, 2
    • B. 1, 3
    • C. 2, 4
    • D. 1, 2, 3
    • Discuss
    • 9. Point out the error in the following program.
      #include<stdio.h>
      #include<stdarg.h>
      void varfun(int n, ...);
      
      int main()
      {
          varfun(3, 7, -11.2, 0.66);
          return 0;
      }
      void varfun(int n, ...)
      {
          float *ptr;
          int num;
          va_start(ptr, n);
          num = va_arg(ptr, int);
          printf("%d", num);
      }
      

    • Options
    • A. Error: too many parameters
    • B. Error: invalid access to list member
    • C. Error: ptr must be type of va_list
    • D. No error
    • Discuss
    • 10. Macros with arguments are allowed

    • Options
    • A. True
    • B. False
    • Discuss


    Comments

    There are no comments.

Enter a new Comment