logo

CuriousTab

CuriousTab

Discussion


Home C Programming Constants See What Others Are Saying!
  • Question
  • Point out the error in the program.
    #include<stdio.h>
    #include<stdlib.h>
    
    union employee
    {
        char name[15];
        int age;
        float salary;
    };
    const union employee e1;
    
    int main()
    {
        strcpy(e1.name, "K");
        printf("%s", e1.name);    
        e1.age=85;
        printf("%d", e1.age);
        printf("%f", e1.salary);
        return 0;
    }
    


  • Options
  • A. Error: RValue required
  • B. Error: cannot modify const object
  • C. Error: LValue required in strcpy
  • D. No error

  • Correct Answer
  • Error: cannot modify const object 


  • More questions

    • 1. Can we pass a variable argument list to a function at run-time?

    • Options
    • A. Yes
    • B. No
    • Discuss
    • 2. Which statement will you add in the following program to work it correctly?
      #include<stdio.h>
      int main()
      {
          printf("%f\n", log(36.0));
          return 0;
      }
      

    • Options
    • A. #include<conio.h>
    • B. #include<math.h>
    • C. #include<stdlib.h>
    • D. #include<dos.h>
    • Discuss
    • 3. The macro va_start is used to initialise a pointer to the beginning of the list of fixed arguments.

    • Options
    • A. True
    • B. False
    • Discuss
    • 4. What will be the output of the program (16-bit platform)?
      #include<stdio.h>
      #include<stdlib.h>
      
      int main()
      {
          int *p;
          p = (int *)malloc(20);
          printf("%d\n", sizeof(p));
          free(p);
          return 0;
      }
      

    • Options
    • A. 4
    • B. 2
    • C. 8
    • D. Garbage value
    • Discuss
    • 5. Bitwise & can be used in conjunction with ~ operator to turn off 1 or more bits in a number.

    • Options
    • A. Yes
    • B. No
    • Discuss
    • 6. Which of the following correctly shows the hierarchy of arithmetic operations in C?

    • Options
    • A. / + * -
    • B. * - / +
    • C. + - / *
    • D. / * + -
    • Discuss
    • 7. Which of the following statements correctly declare a function that receives a pointer to pointer to a pointer to a float and returns a pointer to a pointer to a pointer to a pointer to a float?

    • Options
    • A. float **fun(float***);
    • B. float *fun(float**);
    • C. float fun(float***);
    • D. float ****fun(float***);
    • Discuss
    • 8. The elements of union are always accessed using & operator

    • Options
    • A. Yes
    • B. No
    • Discuss
    • 9. How will you print \n on the screen?

    • Options
    • A. printf("\n");
    • B. echo "\\n";
    • C. printf('\n');
    • D. printf("\\n");
    • Discuss
    • 10. Macros have a local scope.

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


    Comments

    There are no comments.

Enter a new Comment