logo

CuriousTab

CuriousTab

Discussion


Home C Programming Control Instructions See What Others Are Saying!
  • Question
  • Which of the following errors would be reported by the compiler on compiling the program given below?
    #include<stdio.h>
    int main()
    {
        int a = 5;
        switch(a)
        {
    	case 1:
    	printf("First");
    
    	case 2:
    	printf("Second");
    
    	case 3 + 2:
    	printf("Third");
    
    	case 5:
    	printf("Final");
    	break;
    
        }
        return 0;
    }
    


  • Options
  • A. There is no break statement in each case.
  • B. Expression as in case 3 + 2 is not allowed.
  • C. Duplicate case case 5:
  • D. No error will be reported.

  • Correct Answer
  • Duplicate case case 5: 

    Explanation
    Because, case 3 + 2: and case 5: have the same constant value 5.

    More questions

    • 1. What do the following declaration signify?
      void *cmp();

    • Options
    • A. cmp is a pointer to an void type.
    • B. cmp is a void type pointer variable.
    • C. cmp is a function that return a void pointer.
    • D. cmp function returns nothing.
    • Discuss
    • 2. A function may have any number of return statements each returning different values.

    • Options
    • A. True
    • B. False
    • Discuss
    • 3. In C all functions except main() can be called recursively.

    • Options
    • A. True
    • B. False
    • Discuss
    • 4. Input/output function prototypes and macros are defined in which header file?

    • Options
    • A. conio.h
    • B. stdlib.h
    • C. stdio.h
    • D. dos.h
    • Discuss
    • 5. For a function receives variable number of arguments it is necessary that the function should receive at least one fixed argument.

    • Options
    • A. True
    • B. False
    • Discuss
    • 6. What will be the output of the program?
      #include<stdio.h>
      int X=40;
      int main()
      {
          int X=20;
          printf("%d\n", X);
          return 0;
      }
      

    • Options
    • A. 20
    • B. 40
    • C. Error
    • D. No Output
    • Discuss
    • 7. What will be the output of the program (myprog.c) given below if it is executed from the command line?
      cmd> myprog one two three
      /* myprog.c */
      #include<stdio.h>
      #include<stdlib.h>
      
      int main(int argc, char **argv)
      {
          int i;
          for(i=1; i<=3; i++)
              printf("%u\n", &argv[i]);
          return 0;
      }
      
      If the first value printed by the above program is 65517, what will be the rest of output?


    • Options
    • A. 65525 65531
    • B. 65519 65521
    • C. 65517 65517
    • D. 65521 65525
    • Discuss
    • 8. What will be the output of the program?
      #include<stdio.h>
      #include<stdlib.h>
      
      int main()
      {
          int *p;
          p = (int *)malloc(20); /* Assume p has address of 1314 */
          free(p);
          printf("%u", p);
          return 0;
      }
      

    • Options
    • A. 1314
    • B. Garbage value
    • C. 1316
    • D. Random address
    • Discuss
    • 9. Size of short integer and long integer would vary from one platform to another.

    • Options
    • A. True
    • B. False
    • Discuss
    • 10. Names of functions in two different files linked together must be unique

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


    Comments

    There are no comments.

Enter a new Comment