Home / CSE MCQs / C-MCQs :: C Functions

CSE MCQs :: C-MCQs

  1. What is the return-type of the function sqrt()
  2. A.
    int
    B.
    float
    C.
    double
    D.
    Depends on the data type of the parameter

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. Which of the following function declaration is illegal?
  4. A.
    double func();
         int main(){}
         double func(){}
    B.
    double func(){};
         int main(){}
    C.
    int main()
         {
         double func();
         }
    double func(){//statements}
    D.
    None of the mentioned

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. What will be the data type returned for the following function?

        int func()
        {
            return (double)(char)5.0;
        }
  6. A.
    char
    B.
    int
    C.
    double
    D.
    multiple type-casting in return is illegal

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. What is the problem in the following declarations?
         int func(int);
         double func(int);
         int func(float);
  8. A.
    A function with same name cannot have different signatures
    B.
    A function with same name cannot have different return types
    C.
    A function with same name cannot have different number of parameters
    D.
    All of the mentioned

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. The output of the code below is

        void main()
        {

            int k = m();
            printf("%d", k);
        }

        void m()
        {

            printf("hello");
        }

  10. A.
    hello 5
    B.
    Error
    C.
    Nothing
    D.
    Junk value

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. The output of the code below is

        int *m();
        void main()
        {
            int *k = m();
            printf("hello ");
            printf("%d", k[0]);
        }
        int *m()
        {
            int a[2] = {5, 8};
            return a;
        }
  12. A.
    hello 5 8
    B.
    hello 5
    C.
    hello followed by garbage value
    D.
    Compilation error

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. The output of the code below is

        int *m();
        void main()
        {
            int k = m();
            printf("%d", k);
        }
        int *m()
        {
            int a[2] = {5, 8};
            return a;
        }
  14. A.
    5
    B.
    8
    C.
    Nothing
    D.
    Varies

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. The output of the code below is

        void
    m(int k)
        {
            printf("hi");
        }
        void m(double k)
        {
            printf("hello");
        }
        void main()
        {
            m(3);
        }


  16. A.
    hi
    B.
    hello
    C.
    Compile time error
    D.
    Nothing

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. What is the default return type if it is not specified in function definition?
  18. A.
    void
    B.
    int
    C.
    double
    D.
    short int

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. What is the output of this C code?


        int foo();
        int main()
        {
            int i = foo();
        }
        foo()
        {
            printf("2 ");
            return 2;
        }

  20. A.
    2
    B.
    Compile time error
    C.
    Depends on the compiler
    D.
    Depends on the standard

    View Answer

    Workspace

    Discuss Discuss in Forum