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

5/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>
int main()
{
    char i = '9';
    if (isdigit(i))
        printf("digit\n");
    else
        printf("not digit\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()
{
    FILE *fp = stdout;
    int n;
    fprintf(fp, "%d", 45);
}

Select an option to see the answer and solution.

Which of the following is the correct declaration for ungetc?

Select an option to see the answer and solution.

What is the purpose of sprintf?

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 = 10;
    printf("%f\n", log10(i));
    return 0;
}

Select an option to see the answer and solution.

Memory allocation using malloc() is done in . . . . . . . .

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

For the function call time(), what type of parameter is accepted?

Select an option to see the answer and solution.

fwrite() can be used only with files that are opened in binary mode.

Select an option to see the answer and solution.

What is meant by 'a' in the following C operation?
fp = fopen("Random.txt", "a");

Select an option to see the answer and solution.

The parameter control string in the printf () is a C String that contains text to be . . . . . . . .

Select an option to see the answer and solution.

What will be the output of the following C code?
printf(“\n Output: %5d \t %x \t %#x”, 234,234,234);

Select an option to see the answer and solution.

The syntax to print a % using printf statement can be done by . . . . . . . .

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()
{
    srand(9000);
    printf("%d\n", rand());
    return 0;
}

Select an option to see the answer and solution.

The conversion characters d, i, o, u, and x may be preceded by h in scanf() to indicate?

Select an option to see the answer and solution.

The maximum number of characters to be printed is specified by . . . . . . . .

Select an option to see the answer and solution.

In function free(p), p is a . . . . . . . .

Select an option to see the answer and solution.

What will be the output of the following code?
char t=’N’;
printf(“\n %c \n %3c \n %5c”,t,t,t);

Options are not available for this question.

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 argc, char** argv)
{
    char *s = "myworld";
    int i = 3;
    printf("%10.*s", i, s);
}

Select an option to see the answer and solution.

What is the output of the following C code if there is no error in stream fp?
#include <stdio.h>
int main()
{
    FILE *fp;
    fp = fopen("newfile", "w");
    printf("%d\n", ferror(fp));
    return 0;
}

Select an option to see the answer and solution.