1. What will be the output of the following C code?
#include <stdio.h>
int main()
{
FILE *fp = stdin;
int n;
fprintf(fp, "%d", 45);
}
#include <stdio.h>
int main()
{
FILE *fp = stdin;
int n;
fprintf(fp, "%d", 45);
}
2. What will be the output of the following C code?
#include <stdio.h>
#include <string.h>
int main()
{
char *str = "hello, world";
char *str1 = "hello, world";
if (strcmp(str, str1))
printf("equal");
else
printf("unequal");
}
#include <stdio.h>
#include <string.h>
int main()
{
char *str = "hello, world";
char *str1 = "hello, world";
if (strcmp(str, str1))
printf("equal");
else
printf("unequal");
}
3. What is the function of FILE *tmpfile(void)?
4. What happens when zero flag is used with left justification?
5. What will be the output of the following C code?
#include <stdio.h>
int main()
{
int n;
scanf("%d", n);
printf("%d\n", n);
return 0;
}
#include <stdio.h>
int main()
{
int n;
scanf("%d", n);
printf("%d\n", n);
return 0;
}
6. Which of the following is not a valid mathematical function?
7. EOF is an integer type defined in stdio. hand has a value . . . . . . . .
8. What will be the output of the following C code?
#include <stdio.h>
#include <string.h>
int main()
{
char *str = "hello, world";
char str1[9];
strncpy(str1, str, 9);
printf("%s %d", str1, strlen(str1));
}
#include <stdio.h>
#include <string.h>
int main()
{
char *str = "hello, world";
char str1[9];
strncpy(str1, str, 9);
printf("%s %d", str1, strlen(str1));
}
9. What will be the output of the following C code if following commands are used to run and if myfile does not exist?
gcc -o test test.c
./test > myfile
#include <stdio.h>
int main(int argc, char **argv)
{
char c = 'd';
putchar(c);
printf(" %d\n", argc);
}
gcc -o test test.c
./test > myfile
#include <stdio.h>
int main(int argc, char **argv)
{
char c = 'd';
putchar(c);
printf(" %d\n", argc);
}
10. What will be the output of the following C code?
#include <stdio.h>
int main()
{
char c = '�';
putchar(c);
}
#include <stdio.h>
int main()
{
char c = '�';
putchar(c);
}
Read More Section(File Input Output)
Each Section contains maximum 100 MCQs question on File Input Output. To get more questions visit other sections.