Home > C Programming > Quizzes > C Programming Practice Test: C Input and Output
C Programming Practice Test: C Input and Output
Fast practice, instant feedback. Timer auto-submits when time’s up.
Avg score: 0% Most missed: “Which of the following represents the function for scanf()?”

C Input and Output quiz on: Standard input and output, formatted input and output, variable length argument, file access, error handling, line input and output, string operations, character class testing, ungetc, storage management, mathematical functions, random number generation, file operations, printf and scanf.
 

C Programming Practice Test: C Input and Output
Time left 00:00
25 Questions

1. Output justification such as decimal point, numerical sign, trailing zeros or octal are specified.
2. What is the value of EOF?
3. 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
int main(int argc, char **argv)
{
char c = 'd';
putchar(c);
printf(" %d\n", argc);
}
4. ________is used to define the type and the interpretation of the value of the corresponding argument.
5. What is the difference between %e and %g?
6. What is the return value of getc()?
7. What will be the output of the following C code?
#include
int main()
{
FILE *fp = stdout;
int n;
fprintf(fp, "%d\n ", 45);
fprintf(stderr, "%d ", 65);
return 0;
}
8. What is the syntax of ungetc()?
9. Which among the following mathematical function do not have a “double” return-type?
10. Which is true about function tolower?
11. What will be the output of the following C code?
#include
int main()
{
FILE *fp;
char c;
int n = 0;
fp = fopen("newfile1.txt", "r");
while (!feof(fp))
{
c = getc(fp);
putc(c, stdout);
}
}
12. What will be the output of the following C code?
#include
int f(char chr, ...);
int main()
{
char c = 97;
f(c);
return 0;
}
int f(char c, ...)
{
printf("%c\n", c);
}
13. What will fopen will return, if there is any error while opening a file?
14. A conversion specification %7.4f means ____________
15. For binary files, a ___ must be appended to the mode string.
16. What will be the output of the following C code?
#include
int main()
{
char str[10] = "hello";
char *p = strrchr(str, 'l');
printf("%c\n", *(++p));
}
17. What will be the output of the following C code?
#include
#include
int main()
{
char i = 9;
if (isdigit(i))
printf("digit\n");
else
printf("not digit\n");
return 0;
}
18. ungetc() may be used with ________
19. What type of inputs are accepted by mathematical functions?
20. On freeing a dynamic memory, if the pointer value is not modified, then the pointer points to.
21. Only _____character of pushback is guaranteed per file when ungetc is used.
22. When a C program is started, O.S environment is responsible for opening file and providing pointer for that file?
23. What will be the output of the following C code?
#include
#include
int main()
{
srand(9000);
printf("%d\n", rand());
return 0;
}
24. What will be the output of the following C code?
#include
#include
int main()
{
char c = 't';
printf("%d\n", isspace(c));
}
25. What will be the output of the following C code?
#include
int main()
{
printf("%d\n", srand(9000));
return 0;
}