Q.1.

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}
Q.2.

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}
Q.3.

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}
Q.4.

We should not read after a write to a file without an intervening call to fflush(), fseek() or rewind()

Q.5.

What will be the output of the program ?

#include<stdio.h>

int main()
{
    char *p;
    p="%d\n";
    p++;
    p++;
    printf(p-23);
    return}
Q.6.

What will be the output of the program ?

#include<stdio.h>

int main()
{
    float a=3.
    printf("%2.1f\n", a);
    return
}
Q.7.

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}
Q.8.

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}
Q.9.

In a call to printf() function the format specifier %b can be used to print binary equivalent of an integer.

Q.10.

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}
Q.11.

What will be the output of the program ?

#include<stdio.h>

int main()
{
    printf("%%%%\n");
    return}
Q.12.

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?

Q.13.

What is the purpose of "rb" in fopen() function used below in the code?

FILE *fp;
fp = fopen("source.txt", "rb");
Q.14.

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}
Q.15.

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}
Q.16.

Which of the following operations can be performed on the file "NOTES.TXT" using the below code?

FILE *fp;
fp = fopen("NOTES.TXT", "r+");
Q.17.

To scan a and b given below, which of the following scanf() statement will you use?

#include<stdio.h>

float a;
double b;
Q.18.

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.
Q.19.

Out of fgets() and gets() which function is safe to use?

Q.20.

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}