Home > General Studies (Hindi) > 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. 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;
}
2. What will be the output of the following C code?
#include
int main()
{
printf("%d\n", srand(9000));
return 0;
}
3. What is the return type of rand() function?
4. Which pre-defined function returns a pointer to the last occurence of a character in a string?
5. What will be the output of the following C code?
#include
int main()
{
char *s = "myworld";
int i = 9;
printf("%*s", i, s);
}
6. Which of the following represents the function for scanf()?
7. puts() function adds newline character.
8. putchar(c) function/macro always outputs character c to the __________
9. What will be the output of the following C code?
#include
int main()
{
srand(time(NULL));
printf("%d\n", rand());
return 0;
}
10. stderr is similar to?
11. What is meant by ‘a’ in the following C operation?
fp = fopen("Random.txt", "a");
12. Memory allocation using malloc() is done in _________
13. What symbol is used to Left-justify within the data given field width?
14. What will be the output of the following C code?
#include
int main()
{
FILE *fp = stdout;
int n;
fprintf(fp, "%d ", 45);
fflush(stdout);
fprintf(stderr, "%d", 65);
return 0;
}
15. Which of the following doesn’t require an & for the input in scanf()?
16. Which of the following causes an error?
17. fputs() adds newline character.
18. What will be the output of the following C code?
#include
#include
int f(...);
int main()
{
char c = 97;
f(c);
return 0;
}
int f(...)
{
va_list li;
char c = va_arg(li, char);
printf("%c\n", c);
}
19. For the function call time(), what type of parameter is accepted?
20. What type of return-type used in String operations?
21. What is the purpose of va_end?
22. 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);
}
23. What will be the output of the following C code?
#include
int main()
{
char *str = "hello, world";
char str1[15] = "hello wo 9";
strcpy(str, str1);
printf("%s", str1);
}
24. What will be the output of the following C code?
#include
void main()
{
char *p = calloc(100, 1);
p = "welcome";
printf("%s\n", p);
}
25. What will be the output of the following C code?
#include
int main()
{
int i = 10, j = 2;
printf("%d\n", printf("%d %d ", i, j));
}