Error Handling


  1. What will be the output of the following C code?
     #include <stdio.h>
    int main()
    {
    char buff[25];
    stderr = stdin;
    fscanf(stderr, "%s", buff);
    printf("%s\n", buff);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    Whatever user types


  1. What will be the output of the following C code?
    #include <stdio.h>
    int main()
    {
    FILE *fp = stdout;
    stderr = fp;
    fprintf(stderr, "%s", "Interveiw Mania");
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Interveiw Mania



  1. What will be the output of the following C code?
    #include <stdio.h>
    int main()
    {
    FILE *fp;
    char ch;
    int num = 0;
    fp = fopen("file1.txt", "r");
    while (!feof(fp))
    {
    ch = getc(fp);
    putc(ch, stdout);
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Segmentation fault


  1. Within main, return expr statement is equivalent to ________











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    exit(expr)



  1. What is the output of the following C code if there is no error in stream fp?
    #include <stdio.h>
    int main()
    {
    FILE *fp;
    fp = fopen("file1", "w");
    printf("%d\n", ferror(fp));
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    0