C-Library-Functions


  1. What will be the output of the following C code?
    #include <stdio.h>
    int main()
    {
    char num[25];
    fgets(num, 24, stdin);
    ungetc(num[0], stdin);
    scanf("%s", num);
    printf("%s\n", num);
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    First character of whatever user types first time and whatever user types second time


  1. What will be the output of the following C code?
    #include <stdio.h>
    int main()
    {
    int num;
    scanf("%d", &num);
    ungetc(num, stdin);
    scanf("%d", &num);
    printf("%d\n", num);
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    Undefined behaviour



  1. Which character of pushback is guaranteed per file?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    True


  1. ungetc() can be used only with getc().











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    false



  1. What is the return type of rand() function?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    int