adplus-dvertising

Welcome to the File Handling in C MCQs Page

Dive deep into the fascinating world of File Handling in C with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of File Handling in C, a crucial aspect of C Programming. In this section, you will encounter a diverse range of MCQs that cover various aspects of File Handling in C, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within C Programming.

frame-decoration

Check out the MCQs below to embark on an enriching journey through File Handling in C. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of C Programming.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of File Handling in C. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

File Handling in C MCQs | Page 2 of 6

Explore more Topics under C Programming

Discuss
Answer: (c).both a and b
Q12.
What is the output of this program?
#include <stdio.h>
int main(){
    FILE *fp;
    char *str;
    fp=fopen("demo.txt","r");// demo.txt :you are a good programmer
    while(fgets(str,6,fp)!=NULL)
    puts(str);
    fclose(fp);
    return 0;
}
Discuss
Answer: (b).e a good programmer
Q13.
What is the output of this program?
#include <stdio.h>
int main(){
    char c;
    FILE *fp;
    fp=fopen("demo.txt","r");
    while((c=fgetc(fp))!=EOF)
         printf("%c",c);
    fclose(fp);
    return 0;
}
Discuss
Answer: (a).It will print the content of file demo.txt
Q14.
What is the output of this program?
#include <stdio.h>
int main(){
    char c;
    FILE *fp;
    fp=fopen("demo.txt","a+"); // demo.txt : hello you are reading a file
    fprintf(fp," demo");    
 fclose(fp);
    fp=fopen("myfile.txt","r");
    
    while((c=fgetc(fp))!=EOF)
         printf("%c",c);
    fclose(fp);
    return 0;
}
Discuss
Answer: (b).hello you are reading a file demo
Q15.
A data of the file is stored in a
Discuss
Answer: (b).Hard disk
Q16.
Select a function which is used to write a string to a file.
Discuss
Answer: (c).fputs()
Q17.
We should not read after a write to a file without an intervening call to fflush(), fseek() or rewind().
Discuss
Answer: (a).True
Q18.
Offset used in fseek() function call can be a negative number.
Discuss
Answer: (a).True
Q19.
Will the following program work?
#include <stdio.h>
int main()
{
    int i=3;
    printf("i=%*d", i, i);
    return 0;
}
Discuss
Answer: (a).Yes
Q20.
stderr, stdin, stdout are FILE pointers.
Discuss
Answer: (a).Yes
Page 2 of 6

Suggested Topics

Are you eager to expand your knowledge beyond C Programming? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!