Home / C Programming / Complicated Declarations :: Point Out Errors

C Programming :: Complicated Declarations

  1. Point out the error in the following program (in Turbo C under DOS).

     #include
    
      union emp
      {    
           int empno;   
           int age;
       };
      
       int main()
       {   
            union emp e = {10, 25};  
            printf("%d %d", e.empno, e.age);  
            return 0;
        } 
    

  2. A.

    Error: Lvalue required

    B.

    Error: Rvalue required

    C.

    Error: cannot initialize more than one union member.

    D.

    No error

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. Point out the error in the following program.

     #include
     #include
    
      int main() 
      {  
            static char *p = (char *)malloc(10);  
            return 0;
      } 
    

  4. A.

    Error: Lvalue required

    B.

    Error: Rvalue required

    C.

    Error: invalid *p declaration

    D.

    No error

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. Point out the error in the following program.

      #include
      void display(int (*ff)()); 
    
     int main()
     {    
          int show();  
          int (*f)();   
          f = show;  
          display(f);  
          return 0;
      }
      void display(int (*ff)()) 
     {  
         (*ff)();
     } 
     int show()
     {  
       printf("Freshergate");
     } 
    

  6. A.

    Error: invalid parameter in function display()

    B.

    Error: invalid function call f=show;

    C.

    No error and prints "Freshergate"

    D.

    No error and prints nothing.

    View Answer

    Workspace

    Discuss Discuss in Forum