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

12/15

Page

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

Identify X library function for line input and output in the following C code?
#include <stdio.h>
int X(char *s, FILE *iop)
{
    int c;
    while (c = *s++)
    putc(c, iop);
    return ferror(iop) ? EOF : 0;
}

Select an option to see the answer and solution.

What specifies the minimum number of characters to print after being padded with zeros or blank spaces?

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
    char n[20];
    fgets(n, 19, stdin);
    ungetc(n[0], stdin);
    scanf("%s", n);
    printf("%s\n", n);
    return 0;
}

Select an option to see the answer and solution.

What symbol is used to Left-justify within the data given field width?

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>
void func(int, ...);
int main()
{
    func(2, 3, 5, 7, 11, 13);
    return 0;
}
void func(int n, ...)
{
    int number, i = 0;
    va_list start;
    va_start(start, n);
    while (i != 3)
    {
        number = va_arg(start, int);
        i++;
    }
    printf("%d", number);
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
    char n[] = "hello\nworld!";
    char s[13];
    sscanf(n, "%s", s);
    printf("%s\n", s);
    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 <ctype.h>
int main()
{
    int i = 32;
    if (isspace(i))
        printf("space\n");
    else
        printf("not space\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 <stdarg.h>
int f(int c, ...);
int main()
{
    int c = 97;
    float d = 98;
    f(c, d);
    return 0;
}
int f(int c, ...)
{
    va_list li;
    va_start(li, c);
    float d = va_arg(li, float);
    printf("%f\n", d);
    va_end(li);
}

Select an option to see the answer and solution.

The functions vprintf(), vfprintf(), and vsprintf() are not equivalent to the corresponding printf() functions except the variable argument list.

Select an option to see the answer and solution.

Which is true about isalnum(c), where c is an int that can be represented as an unsigned?
char or EOF.isalnum(c) returns

Select an option to see the answer and solution.

Which of the following is used during memory deallocation in C?

Select an option to see the answer and solution.

What is the difference in the ASCII value of capital and non-capital of the same letter is?

Select an option to see the answer and solution.

In the following C program, every time program is run different numbers are generated.
#include <stdio.h>
int main()
{
    srand(time(NULL));
    printf("%d\n", rand());
    return 0;
}

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.

Select the right explanation for the following C code snippet.
int fgetpos(FILE *stream, fpos_t *s)

Select an option to see the answer and solution.

What will be the output of the following C code if 2 characters is typed by the user?
#include <stdio.h>
#include <string.h>
int main()
{
    char line[3];
    fgets(line, 3, stdin);
    printf("%d\n", line[2]);
    return 0;
}

Select an option to see the answer and solution.

What will be the output of the following C code?
char str[] =”Too Good”;
printf(“\n %7s”,str);

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>
void main()
{
    int k = pow(2, 3);
    printf("%d\n", k);
}

Select an option to see the answer and solution.

Which of the following library function is not case-sensitive?

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
    char *s = "myworld";
    int i = 9;
    printf("%*s", i, s);
}

Select an option to see the answer and solution.