Functions


  1. What will be the output of the following C code?
    #include <stdio.h>
    double fun();
    int main()
    {
    fun();
    return 0;
    }
    fun()
    {
    printf("250");
    return 250;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Compilation Error

    main.c:8:5: warning: return type defaults to ‘int’ [-Wimplicit-int]
    fun()
    ^~~
    main.c:8:5: error: conflicting types for ‘fun’
    main.c:2:12: note: previous declaration of ‘fun’ was here
    double fun();


  1. Functions can return structure in C?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    True



  1. Functions can return enumeration constants in C?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    true


  1. What will be the output of the following C code?
    #include <stdio.h>
    enum color{Red, Yellow, Green};
    enum color fun();
    int main()
    {
    enum color n = fun();
    printf("%d\n", n);
    }
    int fun()
    {
    return Red;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Compilation Error

    main.c:9:10: error: conflicting types for ‘fun’
    int fun()
    ^~~
    main.c:3:16: note: previous declaration of ‘fun’ was here
    enum color fun();



  1. What will be the output of the following C code?
    #include <stdio.h>
    struct Employee
    {
    char name[20];
    };
    void main()
    {
    struct Employee emp[] = {"AJIT", "KUMAR"};
    printf("%c", emp[0].name[1]);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    J