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

7/15

Page

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

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What type of return-type used in String operations?

Select an option to see the answer and solution.

The function . . . . . . . . obtains a block of memory dynamically.

Select an option to see the answer and solution.

What happens when we use the following C statement?

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
    FILE *fp = stdout;
    int n;
    fprintf(fp, "%d ", 45);
    fflush(stdout);
    fprintf(stderr, "%d", 65);
    return 0;
}

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
void main()
{
    char *p = calloc(100, 1);
    p = "welcome";
    printf("%s\n", p);
}

Select an option to see the answer and solution.

Explain the format string "%5d%s %c"

Select an option to see the answer and solution.

What is the difference between %e and %g?

Select an option to see the answer and solution.

Strcat() function adds null character.

Select an option to see the answer and solution.

What is the size of array "line" used in fgets(line, maxline, *fp) function?

Select an option to see the answer and solution.

What will be the output of the following C statement?
int ungetc(int c, FILE *fp)

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What does the ungetc function return for the following C expression?
ungetc(c, fp);//where declarations are int c and FILE *fp

Select an option to see the answer and solution.

If the user enters 1 3.2 s, what value will be returned by the scanf()?
scanf("%d %f %c", &s1, &s2, &s3);

Select an option to see the answer and solution.

Why do we write (int *) before malloc?
int *ip = (int *)malloc(sizeof(int));

Select an option to see the answer and solution.

What type of inputs are accepted by mathematical functions?

Select an option to see the answer and solution.

What will be the output of the following C code?
#include <stdio.h>
int main()
{
    FILE *fp;
    char c;
    int n = 0;
    fp = fopen("newfile1.txt", "r");
    while (!feof(fp))
    {
        c = getc(fp);
        putc(c, stdout);
    }
}

Select an option to see the answer and solution.

What will be the output for the given code.
printf("\n The number is %07d",1212);

Select an option to see the answer and solution.

Which of the following will return a result most quickly for searching a given key?

Select an option to see the answer and solution.