File Input Output MCQs

296 questionsC-ProgramPage 24 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 208hard
What will be the output of the following C code?
#include <stdio.h>
#include <string.h>
int main()
{
    char *str = "hello, world";
    char str1[9];
    strncpy(str1, str, 9);
    printf("%s %d", str1, strlen(str1));
}
Question 209hard
What will be the output of the following C code if following commands are used to run and if myfile does not exist?
gcc -o test test.c
./test > myfile

#include <stdio.h>
int main(int argc, char **argv)
{
    char c = 'd';
    putchar(c);
    printf(" %d\n", argc);
}
Question 210medium
What will be the output of the following C code?
#include <stdio.h>
int main()
{
    char c = '�';
    putchar(c);
}
Advertisement
Question 211easy
What is function srand(unsigned)?
Question 212easy
What is the purpose of the C function?
int ferror(FILE *fp)
Question 213medium
What if size is zero in the following C statement?
realloc(ptr, size)
Advertisement
Question 214medium
Select the right explanation to the given code.
printf(“%*. *f”, 5,4,5700);
Question 215hard
Which of the following should be used for freeing the memory allocated in the following C code?
#include <stdio.h>
struct p
{
    struct p *next;
    int x;
};
int main()
{
    struct p *p1 = (struct p*)malloc(sizeof(struct p));
    p1->x = 1;
    p1->next = (struct p*)malloc(sizeof(struct p));
    return 0;
}
Question 216medium
Which of the following function with ellipsis are illegal?