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 27 of 42

Explore more Topics under C Programming

Q261.
Point out the error in the program?
#include<stdio.h>

int main()
{
    char ch;
    int i;
    scanf("%c", &i);
    scanf("%d", &ch);
    printf("%c %d", ch, i);
    return 0;
}
Discuss
Answer: (b).Error: we may not get input for second scanf() statement
Q262.
Point out the error in the program?
#include<stdio.h>

int main()
{
    FILE *fp;
    fp=fopen("trial", "r");
    fseek(fp, "20", SEEK_SET);
    fclose(fp);
    return 0;
}
Discuss
Answer: (b).Error: fseek() long offset value
Q263.
Point out the error in the program?
#include<stdio.h>

/* Assume there is a file called 'file.c' in c:\tc directory. */
int main()
{
    FILE *fp;
    fp=fopen("c:\tc\file.c", "r");    
    if(!fp) 
      printf("Unable to open file.");        

    fclose(fp);
    return 0;
}
Discuss
Answer: (c).Output: Unable to open file.
Q264.
Point out the error/warning in the program?
#include<stdio.h>

int main()
{
    unsigned char ch;
    FILE *fp;
    fp=fopen("trial", "r");
    while((ch = getc(fp))!=EOF)
        printf("%c", ch);
    fclose(fp);
    return 0;
}
Discuss
Answer: (a).Error: in unsigned char declaration
Q265.
Which of the following statement is correct about the program?
#include<stdio.h>

int main()
{
    FILE *fp;
    char ch;
    int i=1;
    fp = fopen("myfile.c", "r");
    while((ch=getc(fp))!=EOF)
    {
        if(ch == '\n')
            i++;
    }
    fclose(fp);
    return 0;
}
Discuss
Answer: (d).The code counts number of lines in the file
Q266.
Which of the following statement is correct about the program?
#include<stdio.h>

int main()
{
    FILE *fp;
    char str[11], ch;
    int i=0;
    fp = fopen("INPUT.TXT", "r");
    while((ch=getc(fp))!=EOF)
    {
        if(ch == '\n' || ch == ' ')
        {
            str[i]='\0';
            strrev(str);
            printf("%s", str);
            i=0;
        }
        else
            str[i++]=ch;
    }
    fclose(fp);
    return 0;
}
Discuss
Answer: (b).The code reads a text files and display its content in reverse order
Q267.
Point out the correct statements about the program?
#include<stdio.h>

int main()
{
    FILE *fptr;
    char str[80];
    fptr = fopen("f1.dat", "w");
    if(fptr == NULL)
        printf("Cannot open file");
    else
    {
        while(strlen(gets(str))>0)
        {
            fputs(str, fptr);
            fputs("\n", fptr);
        }
        fclose(fptr);
    }
    return 0;
}
Discuss
Answer: (b).The code writes strings that are read from the keyboard into a file.
Q268.
The maximum combined length of the command-line arguments including the spaces between adjacent arguments is
Discuss
Answer: (d).It may vary from one operating system to another
Q269.
According to ANSI specifications which is the correct way of declaring main when it receives command-line arguments?
Discuss
Answer: (a).int main(int argc, char *argv[])
Discuss
Answer: (c).'c' means argument count 'v' means argument vector

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!