File Input Output - Study Mode
[#221] What will be the output of the following C code? scanf(ā %d %d %dā,&n1,&n2)
Correct Answer
(B) generate error
[#222] What will be the output of the following C code? #include <stdio.h>
int main()
{
int i = 10, j = 2
printf("%d
", printf("%d %d ", i, j))
}
Correct Answer
(D) 10 2 5
(H) 10 2 5
[#223] What will be the output of the following C code? #include <stdio.h>
#include <stdarg.h>
int f(char c, ...)
int main()
{
char c = 97, d = 98
f(c, d)
return 0
}
int f(char c, ...)
{
va_list li
va_start(li, c)
char d = va_arg(li, char)
printf("%c
", d)
va_end(li)
}
Correct Answer
(B) Undefined behaviour
[#224] What will be the output of the following C code? #include <stdio.h>
int main()
{
srand(time(NULL))
printf("%d
", rand())
return 0
}
Correct Answer
(B) An integer in the range 0 to RAND_MAX
[#225] What will be the output of the following C code? #include <stdio.h>
#include <string.h>
int main()
{
char line[3]
FILE *fp
fp = fopen("newfile.txt", "r")
while (fgets(line, 3, fp))
fputs(line, stdout)
return 0
}
Correct Answer
(C) Segmentation fault