Home / C Programming / Functions :: Point Out Errors

C Programming :: Functions

  1. Point out the error in the program

     f(int a, int b)
     {     
        int a;   
        a = 20;   
        return a; 
     }
    

  2. A.

    Missing parenthesis in return statement

    B.

    The function should be defined as int f(int a, int b)

    C.

    Redeclaration of a

    D.

    None of above

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. Point out the error in the program

    #include
     int f(int a) 
     {
       a > 20? return(10): return(20);
     } 
     int main()
     {    
       int f(int);    
       int b;    
       b = f(20);     
       printf("%d\n", b);    
       return 0;
     }
    

  4. A.

    Error: Prototype declaration

    B.

    No error

    C.

    Error: return statement cannot be used with conditional operators

    D.

    None of above

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. Point out the error in the program

    #include
    
     int main()
     {     
        int a=10;  
        void f();     
        a = f();    
        printf("%d\n", a);   
        return 0;
     } 
     void f() 
     {    
        printf("Hi"); 
     } 

     

  6. A.

    Error: Not allowed assignment

    B.

    Error: Doesn't print anything

    C.

    No error

    D.

    None of above

    View Answer

    Workspace

    Discuss Discuss in Forum