Vidyalelo
C Programming · all questions

File Input Output
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

296

Questions

13/15

Page

Pick an option on a question to see the right answer and solution.

What is the prototype of scanf function?

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
#include <math.h>
int main()
{
    int i = 90;
    printf("%f\n", sin(i));
    return 0;
}

Select an option to see the answer and solution.

Which type of files can't be opened using fopen()?

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
    int i = 10, j = 3, k = 3;
    printf("%d %d ", i, j, k);
}

Select an option to see the answer and solution.

What will be the output of the following C function when EOF returns?
int fputs(char *line, FILE *fp)

Select an option to see the answer and solution.

A conversion specification %7.4f means . . . . . . . .

Select an option to see the answer and solution.

puts() function adds newline character.

Select an option to see the answer and solution.

The . . . . . . . . function reads atmost one less than the number of characters specified by size from the given stream and it is stored in the string str.

Select an option to see the answer and solution.

What does tmpfile() returns when it could not create the file?

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
    int n;
    scanf("%d", &n);
    ungetc(n, stdin);
    scanf("%d", &n);
    printf("%d\n", n);
    return 0;
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
#include <stdlib.h>
int main()
{
    printf("%d\n", rand() % 1000);
    return 0;
}

Select an option to see the answer and solution.

If the mode includes b after the initial letter, what does it indicates?

Select an option to see the answer and solution.

What will be the output of the following C code if following commands are used to run (considering myfile exists)?
gcc -otest test.c
./test > myfile

 #include <stdio.h>
int main(int argc, char **argv)
{
    char c = 'd';
    putchar(c);
    printf(" %d\n", argc);
}

Select an option to see the answer and solution.

What will be the output of the following C code?
scanf(“ %d %d %d”,&n1,&n2);

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
    int i = 10, j = 2;
    printf("%d\n", printf("%d %d ", i, j));
}

Select an option to see the answer and solution.

A fatal error will be generated if the format string is ended with a white space character.

Select an option to see the answer and solution.

Which of the following mode argument is used to truncate?

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
#include <stdarg.h>
int f(char c, ...);
int main()
{
    char c = 97, d = 98;
    f(c, d);
    return 0;
}
int f(char c, ...)
{
    va_list li;
    va_start(li, c);
    char d = va_arg(li, char);
    printf("%c\n", d);
    va_end(li);
}

Select an option to see the answer and solution.

What does the following command line signify?
prog1|prog2

Select an option to see the answer and solution.

Which function has a return type as char pointer?

Select an option to see the answer and solution.