logo

CuriousTab

CuriousTab

Discussion


Home C Programming Functions Comments

  • Question
  • Will the following functions work?
    int f1(int a, int b)
    {
        return ( f2(20) );
    }
    int f2(int a)
    {
        return (a*a);
    }
    


  • Options
  • A. Yes
  • B. No

  • Correct Answer
  • Yes 

    Explanation
    Yes, It will return the value 20*20 = 400

    Example:

    
    #include <stdio.h>
    int f1(int, int); /* Function prototype */
    int f2(int); /* Function prototype */
    
    int main()
    {
        int a = 2, b = 3, c;
        c = f1(a, b);
        printf("c = %d\n", c);
        return 0;
    }
    
    int f1(int a, int b)
    {
        return ( f2(20) );
    }
    
    int f2(int a)
    {
        return (a * a);
    }
    

    Output:
    c = 400


    Functions problems


    Search Results


    • 1. Every function must return a value

    • Options
    • A. Yes
    • B. No
    • Discuss
    • 2. Maximum number of arguments that a function can take is 12

    • Options
    • A. Yes
    • B. No
    • Discuss
    • 3. Functions cannot return a floating point number

    • Options
    • A. Yes
    • B. No
    • Discuss
    • 4. If a function contains two return statements successively, the compiler will generate warnings. Yes/No?

    • Options
    • A. Yes
    • B. No
    • Discuss
    • 5. Names of functions in two different files linked together must be unique

    • Options
    • A. True
    • B. False
    • Discuss
    • 6. In a function two return statements should never occur.

    • Options
    • A. Yes
    • B. No
    • Discuss
    • 7. Usually recursion works slower than loops.

    • Options
    • A. Yes
    • B. No
    • Discuss
    • 8. Is it true that too many recursive calls may result into stack overflow?

    • Options
    • A. Yes
    • B. No
    • Discuss
    • 9. What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          char *str;
          str = "%d\n";
          str++;
          str++;
          printf(str-2, 300);
          return 0;
      }
      

    • Options
    • A. No output
    • B. 30
    • C. 3
    • D. 300
    • Discuss
    • 10. What will be the output of the program?
      #include<stdio.h>
      
      int main()
      {
          char *str;
          str = "%s";
          printf(str, "K\n");
          return 0;
      }
      

    • Options
    • A. Error
    • B. No output
    • C. K
    • D. %s
    • Discuss


    Comments

    There are no comments.

Enter a new Comment