File Input Output MCQs

296 questionsC-ProgramPage 25 of 33

Practice free File Input Output multiple-choice questions with instant answer feedback and step-by-step solutions. Click an option to check yourself, reveal the full explanation, and work through all 296 questions — no login required.

Question 217hard
What will be the output of the following C code?
#include <stdio.h>
struct p
{
    struct p *next;
    int x;
};
int main()
{
    struct p *p1 = calloc(1, sizeof(struct p));
    p1->x = 1;
    p1->next = calloc(1, sizeof(struct p));
    printf("%d\n", p1->next->x);
    return 0;
}
Question 218medium
Which of the following mathematical function requires 2 parameter for successful function call?
Question 219medium
How many characters for pushback is guaranteed per file while using ungetc(c, fp);?
Advertisement
Question 220medium
Which of the following function can be used to terminate the main() function from another function safely?
Question 221hard
Identify X library function for line input and output in the following C code?
#include <stdio.h>
int X(char *s, FILE *iop)
{
    int c;
    while (c = *s++)
    putc(c, iop);
    return ferror(iop) ? EOF : 0;
}
Question 222easy
What specifies the minimum number of characters to print after being padded with zeros or blank spaces?
Advertisement
Question 223hard
What will be the output of the following C code?
#include <stdio.h>
int main()
{
    char n[20];
    fgets(n, 19, stdin);
    ungetc(n[0], stdin);
    scanf("%s", n);
    printf("%s\n", n);
    return 0;
}
Question 224medium
What symbol is used to Left-justify within the data given field width?
Question 225hard
What will be the output of the following C code?
#include <stdio.h>
#include <stdarg.h>
void func(int, ...);
int main()
{
    func(2, 3, 5, 7, 11, 13);
    return 0;
}
void func(int n, ...)
{
    int number, i = 0;
    va_list start;
    va_start(start, n);
    while (i != 3)
    {
        number = va_arg(start, int);
        i++;
    }
    printf("%d", number);
}