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 25

Which of the following statements about stdout and stderr are true?

Same 
Both connected to screen always.
Both connected to screen by default.
stdout is line buffered but stderr is unbuffered.
SHOW ANSWER

Which type of files can’t be opened using fopen()?

.txt
.bin
 .c
None of the above
SHOW ANSWER

When a C program is started, O.S environment is responsible for opening file and providing pointer for that file?

Standard input 
Standard output 
C. Standard error 
D. All of the above
Standard error
All of the above
SHOW ANSWER

What is the output of this program by manipulating the text file?
#include <stdio.h> 
int main() 

    if (remove("myfile.txt") != 0) 
        perror("Error"); 
    else
        puts("Success"); 
    return 0; 

Error
Success
Runtime Error
Can’t say
SHOW ANSWER

What is the output of this program?
#include <stdio.h> 
int main() 

    FILE* p; 
    int c; 
    int n = 0; 
    p = fopen("myfile.txt", "r"); 
    if (p == NULL) 
        perror("Error opening file"); 
    else { 
        do { 
            c = getc(p); 
            if (c == '$') 
                n++; 
        } while (c != EOF); 
        fclose(p); 
        printf("%d\n", n); 
    } 
    return 0; 
}

Count of ‘$’ symbol
Error opening file
Any of the mentioned
None of the mentioned
SHOW ANSWER

What is the output of this program in the text file?
#include <stdio.h> 
int main() 

    FILE* pFile; 
    char c; 
    pFile = fopen("sample.txt", "wt"); 
    for (c = 'A'; c <= 'E'; c++) { 
        putc(c, pFile); 
    } 
    fclose(pFile); 
    return 0; 

ABCD
ABC
ABCDE
None of the mentioned
SHOW ANSWER

What is the name of the myfile2 file after executing this program?
#include <stdio.h> 
int main() 

    int result; 
    char oldname[] = "myfile2.txt"; 
    char newname[] = "newname.txt"; 
    result = rename(oldname, newname); 
    if (result == 0) 
        puts("success"); 
    else
        perror("Error"); 
    return 0; 

name
new
newname
None of the mentioned
SHOW ANSWER

How many number of characters are available in newname.txt?
#include <stdio.h> 
int main() 

    FILE* p; 
    int n = 0; 
    p = fopen("newname.txt", "rb"); 
    if (p == NULL) 
        perror("Error opening file"); 
    else { 
        while (fgetc(p) != EOF) { 
            ++n; 
        } 
        if (feof(p)) { 
            printf("%d\n", n); 
        } else
            puts("End-of-File was not reached."); 
        fclose(p); 
    } 
    return 0; 

10
15
Depends on the text file
 None of the mentioned
SHOW ANSWER

In context to file handling, Which of the following are file handling operations?

opening
closing
read/write
all of above
SHOW ANSWER

Which of the following methods can be used to open a file in file handling?

Using Open ( )
Constructor method
Destructor method
Both a and b
SHOW ANSWER

To perform File I/O operations, Which of the following header files is used?

&lt; ifstream&gt;
&lt; ofstream&gt;
&lt; fstream&gt;
Any of these
SHOW ANSWER

Out of the following options, object of which class is declared in order to
create an output stream

ofstream
ifstream
iostream
None of these
SHOW ANSWER

In which of the following classes, Streams that will be performing both input
and output operations must be declared?

iostream
fstream
stdstream
stdiostream
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