NEW
Font size
WorksheetsEOF is an integer type defined in stdio.h and has a value ______
Total questions: 15
Worksheet time: 30mins
What is the output of the following C code if there is no error in stream fp?
#include <stdio.h>
int main()
{
FILE *fp;
fp = fopen("newfile", "w");
printf("%d\n", ferror(fp));
return 0;
}
Compilation error
0
1
Any nonzero value
Within main, return expr statement is equivalent to ________
abort(expr)
exit(expr)
ferror(expr)
none of the mentioned
What will be the output of the following C code? (Assuming the newfile1.txt exists)
#include <stdio.h>
int main()
{
FILE *fp;
char c;
int n = 0;
fp = fopen("newfile1.txt", "r");
while (!feof(fp))
{
c = getc(fp);
putc(c, stdout);
}
}
Compilation error
Prints to the screen content of newfile1.txt completely
Prints to the screen some contents of newfile1.txt
None of the mentioned
What will be the output of the following C code?
#include <stdio.h>
int main()
{
FILE *fp = stdout;
stderr = fp;
fprintf(stderr, "%s", "hello");
}
Compilation error
hello
Undefined behaviour
Depends on the standard
What will be the output of the following C code?
#include <stdio.h>
int main()
{
char buf[12];
stderr = stdin;
fscanf(stderr, "%s", buf);
printf("%s\n", buf);
}
Compilation error
Undefined behaviour
Whatever user types
None of the mentioned
stderr is similar to?
stdin
stdout
both stdout and stdin
none of the mentioned
What happens when we use the following C statement?
fprintf(stderr, "error: could not open filen");
The diagnostic output is directly displayed in the output
The diagnostic output is pipelined to the output file
The line which caused error is compiled again
The program is immediately aborted
Which of the following function can be used to terminate the main function from another function safely?
return(expr);
exit(expr);
abort();
both exit(expr); and abort();
Which one of the following is correct syntax for opening a file.
FILE fopen(const filename, const char *mode)
FILE fopen(const filename)
FILE open(const filename, const char *mode)
FILE open(const*filename)
What is the function of the mode ‘ w+’?
create text file for writing, discard previous contents if any
create text file for update, discard previous contents if any
create text file for writing, do not discard previous contents if any
create text file for update, do not discard previous contents if any
If the mode includes b after the initial letter, what does it indicates?
text file
big text file
binary file
blueprint text
fflush(NULL) flushes all------------------
input streams
output streams
previous contents
appended text
_____removes the named file, so that a subsequent attempt to open it will fail.
remove(const *filename)
remove(filename)
remove()
fclose(filename)
What does tmpfile() returns when it could not create the file?
stream and NULL
only stream
only NULL
does not return anything
EOF is an integer type defined in stdio.h and has a value ____________
1
0
NULL
-1
