Call
whatsapp
9447387064 | 9847003556
0471-2335855 | 8089080088 | 0471-2334855
9447387064 | 9847003556
0471-2335855 | 8089080088 | 0471-2334855
Cisco Training in Trivandrum, Trinity Technologies

No.1 Training Institute in Kerala

C PROGRAM QUESTIONS : PART 27

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?

"I am a boy\r\n\0"
"I am a boy\r\0"
"I am a boy\n\0"
"I am a boy"
SHOW ANSWER

What is the purpose of "rb" in fopen() function used below in the code?
FILE *fp;
fp = fopen("source.txt", "rb");

open "source.txt" in binary mode for reading
open "source.txt" in binary mode for reading and writing
Create a new file "source.txt" for reading and writing
None of above
SHOW ANSWER

What does fp point to in the program ?
#include<stdio.h>
int main()
{
    FILE *fp;
    fp=fopen("trial", "r");
    return 0;
}

The first character in the file
A structure which contains a char pointer which points to the first character of a file.
The name of the file.
The last character in the file.
SHOW ANSWER

Which of the following operations can be performed on the file "NOTES.TXT" using the below code?
FILE *fp;
fp = fopen("NOTES.TXT", "r+");

Reading
Writing
Appending
Read and Write
SHOW ANSWER

To print out a and b given below, which of the following printf() statement will you use?
#include<stdio.h>
float a=3.14;
double b=3.14;

printf("%f %lf", a, b);
printf("%Lf %f", a, b);
printf("%Lf %Lf", a, b);
printf("%f %Lf", a, b);
SHOW ANSWER

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 0;
}

"A.C" "B.C" "C.C"
"B.C" "C.C"
"A.C"
Error in fclose()
SHOW ANSWER

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[20] = "source.txt", target[20]="target.txt", t;
    FILE *fs, *ft;
    fs = fopen(source, "r");
    ft = fopen(target, "w");
    while(1)
    {
        ch=getc(fs);
        if(ch==EOF)
            break;
        else
        {
            fseek(fs, 4L, SEEK_CUR);
            fputc(ch, ft);
        }
    }
    return 0;
}

r n
Trh
err
None of above
SHOW ANSWER

To scan a and b given below, which of the following scanf() statement will you use?
#include<stdio.h>
float a;
double b;

scanf("%f %f", &a, &b);
scanf("%Lf %Lf", &a, &b);
scanf("%f %Lf", &a, &b);
scanf("%f %lf", &a, &b);
SHOW ANSWER

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

gets()
fgets()
SHOW ANSWER

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 0;
}

size of "DUMMY.C" file
The handle associated with "DUMMY.C" file
Garbage value
Error in fileno()
SHOW ANSWER

Which of the following true about FILE *fp

FILE is a keyword in C for representing files and fp is a variable of FILE type.
FILE is a structure and fp is a pointer to the structure of FILE type
FILE is a stream
FILE is a buffered stream
SHOW ANSWER

When fopen() is not able to open a file, it returns

EOF
NULL
Runtime Error
Compiler Dependent
SHOW ANSWER

Who is father of C Language?

Bjarne Stroustrup
Dennis Ritchie
James A. Gosling
Dr. E.F. Codd
SHOW ANSWER
BACK | NEXT
TRINITY SOFTWARE SOLUTIONS,IInd floor, Radheyam Towers, Gandhari Amman Kovil Road, Pulimood, Trivandrum - 1
0471-2334855 | 2335855 | 9447387064 | 9847003556 info@trinitytechnology.in