File Input Output - Study Mode
[#216] What will be the output of the following C code? char str[] =”Good”
scanf(“%s”, str)
Correct Answer
(C) good
[#217] 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
}
Correct Answer
(A) 45 65
[#218] What will be the output of the following C code? #include <stdio.h>
void main()
{
char *p = calloc(100, 1)
p = "welcome"
printf("%s
", p)
}
Correct Answer
(D) welcome
[#219] What will be the output of the following C code? #include <stdio.h>
#include <stdlib.h>
int main()
{
printf("%d
", rand() % 1000)
return 0
}
Correct Answer
(C) An integer between 0-999 including 0 and 999
[#220] 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 <stdio.h>
int main(int argc, char **argv)
{
char c = 'd'
putchar(c)
printf(" %d
", argc)
}
Correct Answer
(B) d 1 in myfile