adplus-dvertising

Welcome to the Input and Output in C MCQs Page

Dive deep into the fascinating world of Input and Output in C with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Input and Output in C, a crucial aspect of C Programming. In this section, you will encounter a diverse range of MCQs that cover various aspects of Input and Output 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 Input and Output 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 Input and Output in C. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Input and Output in C MCQs | Page 24 of 42

Explore more Topics under C Programming

Q231.
To scan a and b given below, which of the following scanf() statement will you use?
#include<stdio.h>

float a;
double b;
Discuss
Answer: (d).scanf("%f %lf", &a, &b);
Q232.
Out of fgets() and gets() which function is safe to use?
Discuss
Answer: (b).fgets()
Q233.
Consider the following program and what will be content of t?
#include<stdio.h>

int main()
{
    FILE *fp;
    int t;
    fp = fopen("DUMMY.C", "w");
    t = fileno(fp);
    printf("%d\n", t);
    return 0;
}
Discuss
Answer: (b).The handle associated with "DUMMY.C" file
Q234.
What will be the content of 'file.c' after executing the following program?
#include<stdio.h>

int main()
{
    FILE *fp1, *fp2;
    fp1=fopen("file.c", "w");
    fp2=fopen("file.c", "w");
    fputc('A', fp1);
    fputc('B', fp2);
    fclose(fp1);
    fclose(fp2);
    return 0;
}
Discuss
Answer: (a).B
Q235.
What will be the output of the program ?
#include<stdio.h>

int main()
{
    int k=1;
    printf("%d == 1 is" "%s\n", k, k==1?"TRUE":"FALSE");
    return 0;
}
Discuss
Answer: (b).1 == 1 is TRUE
Q236.
What will be the output of the program ?
#include<stdio.h>
char *str = "char *str = %c%s%c; main(){ printf(str, 34, str, 34);}";

int main()
{
    printf(str, 34, str, 34);
    return 0;
}
Discuss
Answer: (a).char *str = "char *str = %c%s%c; main(){ printf(str, 34, str, 34);}"; main(){ printf(str, 34, str, 34);}
Q237.
If the file 'source.txt' contains a line "Be my friend" which of the following will be the output of below program?
#include<stdio.h>

int main()
{
    FILE *fs, *ft;
    char c[10];
    fs = fopen("source.txt", "r");
    c[0] = getc(fs);
    fseek(fs, 0, SEEK_END);
    fseek(fs, -3L, SEEK_CUR);
    fgets(c, 5, fs);
    puts(c);
    return 0;
}
Discuss
Answer: (c).end
Q238.
What will be the output of the program ?
#include<stdio.h>

int main()
{
    float a=3.15529;
    printf("%2.1f\n", a);
    return 0;
}
Discuss
Answer: (c).3.2
Q239.
What is the purpose of "rb" in fopen() function used below in the code?
FILE *fp;
fp = fopen("source.txt", "rb");
Discuss
Answer: (a).open "source.txt" in binary mode for reading
Q240.
What does fp point to in the program ?
#include<stdio.h>

int main()
{
    FILE *fp;
    fp=fopen("trial", "r");
    return 0;
}
Discuss
Answer: (b).A structure which contains a char pointer which points to the first character of a file.

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!