If the file 'source.txt' contains a line "Be my friend" which of the following will be the output of below program?
#include<stdio.h>
int main()
{
FILE *fs, *ft;
char c[10];
fs = fopen("source.txt", "r");
c[= getc(fs);
fseek(fs,SEEK_END);
fseek(fs, -3L, SEEK_CUR);
fgets(c,fs);
puts(c);
return}
What will be the output of the program ?
#include<stdio.h>
int main()
{
FILE *fp;
char ch, str[7];
fp=fopen("try.c", "r"); /* file 'try.c' contains "This is Nagpur" */
fseek(fp, 9L, SEEK_CUR);
fgets(str,fp);
puts(str);
return}
Point out the error in the program?
#include<stdio.h>
/* Assume there is a file called 'file.c' in c:\tc directory. */
int main()
{
FILE *fp;
fp=fopen("c:\tc\file.c", "r");
if(!fp)
printf("Unable to open file.");
fclose(fp);
return}
We should not read after a write to a file without an intervening call to fflush(), fseek() or rewind()
What will be the output of the program ?
#include<stdio.h>
int main()
{
char *p;
p="%d\n";
p++;
p++;
printf(p-23);
return}
What will be the output of the program ?
#include<stdio.h>
int main()
{
float a=3.
printf("%2.1f\n", a);
return
}
What will be the output of the program if value 25 given to scanf()?
#include<stdio.h>
int main()
{
int i;
printf("%d\n", scanf("%d", &i));
return}
Point out the error/warning in the program?
#include<stdio.h>
int main()
{
unsigned char ch;
FILE *fp;
fp=fopen("trial", "r");
while((ch = getc(fp))!=EOF)
printf("%c", ch);
fclose(fp);
return}
In a call to printf() function the format specifier %b can be used to print binary equivalent of an integer.
What will be the output of the program ?
#include<stdio.h>
int main()
{
FILE *ptr;
char i;
ptr = fopen("myfile.c", "r");
while((i=fgetc(ptr))!=NULL)
printf("%c", i);
return}
What will be the output of the program ?
#include<stdio.h>
int main()
{
printf("%%%%\n");
return}
In a file contains the line "I am a boy\r\n" then on reading this line into the array str using fgets(). What will str contain?
What is the purpose of "rb" in fopen() function used below in the code?
FILE *fp;
fp = fopen("source.txt", "rb");
Which files will get closed through the fclose() in the following program?
#include<stdio.h>
int main()
{
FILE *fs, *ft, *fp;
fp = fopen("A.C", "r");
fs = fopen("B.C", "r");
ft = fopen("C.C", "r");
fclose(fp, fs, ft);
return}
On executing the below program what will be the contents of 'target.txt' file if the source file contains a line "To err is human"?
#include<stdio.h>
int main()
{
int i, fss;
char ch, source[= "source.txt", target[20]="target.txt", t;
FILE *fs, *ft;
fs = fopen(source, "r");
ft = fopen(target, "w");
while( {
ch=getc(fs);
if(ch==EOF)
break;
else
{
fseek(fs, 4L, SEEK_CUR);
fputc(ch, ft);
}
}
return}
Which of the following operations can be performed on the file "NOTES.TXT" using the below code?
FILE *fp;
fp = fopen("NOTES.TXT", "r+");
To scan a and b given below, which of the following scanf() statement will you use?
#include<stdio.h>
float a;
double b;
To print out a and b given below, which of the following printf() statement will you use?
#include<stdio.h>
float a=3.double b=3.Out of fgets() and gets() which function is safe to use?
Consider the following program and what will be content of t?
#include<stdio.h>
int main()
{
FILE *fp;
int t;
fp = fopen("DUMMY.C", "w");
t = fileno(fp);
printf("%d\n", t);
return}