Maths test
September 4, 2021
Python Intro test
March 6, 2022
Show all

C++ Test -Beginners

1

Data Files

1 / 100

A basic element of data in a file.

2 / 100

Which one of the following explains the sequential file access method?

3 / 100

Mapping of file is managed by ____________

4 / 100

File type can be represented by ____________

5 / 100

What is the output of this C code?
#include
int main()
{
FILE *fp = stdout;
int n;
fprintf(fp, "%d ", 45);
fflush(stdout);
fprintf(stderr, "%d", 65);
return 0;
}

6 / 100

What is the output of this C code?

#include
int main()
{
FILE *fp = stdout;
int n;
fprintf(fp, "%dn ", 45);
fprintf(stderr, "%d ", 65);
return 0;
}

7 / 100

What is the output of this C code?

#include
int main()
{
FILE *fp = stdout;
int n;
fprintf(fp, "%d ", 45);
fprintf(stderr, "%d ", 65);
return 0;
}

8 / 100

stdout, stdin and stderr are

9 / 100

What is the output of this C code?

#include
#include
int main()
{
FILE *fp = stdout;
int n;
fprintf(fp, "%d", 45);
}

10 / 100

What is the output of this C code?

#include
int main()
{
FILE *fp = stdin;
int n;
fprintf(fp, "%d", 45);
}

11 / 100

How do you open a file for binary IO?

12 / 100

What flag do you need to pass to fopen to append to an existing file instead of recreating the file?

13 / 100

How do you write a string of text into a file?

14 / 100

Before you can read or write to a file in C, what do you need to do?

15 / 100

What object do you use to represent a file in C

16 / 100

Where is a file temporarily stored before read or write operation in C language.?

17 / 100

What is a C FILE data type.?

18 / 100

What is the need for a File when you can store anything in memory.?

19 / 100

The value of EOF is_____

20 / 100

Select which is true about a stream…

21 / 100

Select which is true about a stream _______

22 / 100

Select text file in which number will take.

23 / 100

Choose a correct statement about C file "R" mode operation using fopen.
fopen("abc.txt","r");

24 / 100

Choose a correct statement about FGETS in C program.
int main()
{
FILE *fp;
char str[80];
fp=fopen("readme.txt","r");
while(fgets(str,80,fp) != NULL)
{
printf("%s",str);
}
fclose(fp);
}

25 / 100

If a FILE pointer is NULL what does it mean?
FILE *fp;
fp=fopen("abc.txt","w");

26 / 100

What is the keyword used to declare a C file pointer?

27 / 100

What is the Cfunction used tomove current pointer to the beginning of file?
FILE *fp;

28 / 100

Choose a correct statement about opening a file in binary mode for reading.
FILE *fp;
fp=fopen("abc.txt","rb");

29 / 100

Choose a correct statement about C file mode "a+".
FILE *fp;
fp=fopen("abc.txt","a+);

30 / 100

Choose a correct statement about C file mode "a".
FILE *fp;
fp=fopen("abc.txt","a");

31 / 100

File Pointer is a

32 / 100

File Opening is

33 / 100

What will be the output of the C program?

#include
int main()
{
fprintf(&_streams[1], "This will display");
return 0;
}

34 / 100

What will be the output of the C program?

/*This program uses the file "int_numbers.txt"*/
/*4 5 6 5*/
#include
int main()
{
int num[4];
int i = 0, tot = 0;
FILE *fptr;
fptr = fopen("int_numbers.txt", "r");
if(fptr == NULL)
{
printf("File not exist");
}
for(i = 0; i < 4; i++) { fscanf(fptr, "%d,", &num[i]); } for(i = 0; i < 4; i++) { printf("%d ", num[i]); tot = tot + num[i]; } printf("tot = %d", tot); fclose(fptr); return 0; }

35 / 100

What will be the output of the C program?

/*The file datafile.txt is already exists.*/
/*This program uses the datafile.txt which contains the following data*/
/*Hai. This is quiz.com.*/
#include
int main()
{
char *str;
fptr = fopen("datafile.txt", "r");
fgets(str, 22, fptr);
printf("%s", str);
return 0;
}

36 / 100

What will be the output of the C program?

/*The file datafile.txt is already exists.*/
/*This program uses the datafile.txt which contains the following data*/
/*Hai. This is quiz.com.*/
#include
int main()
{
char ch;
FILE *fptr;
fptr = fopen("datafile.txt", "r+");
fprintf(fptr, "Welcome. ");
fclose(fptr);
fptr = fopen("datafile.txt", "r");
while((ch = fgetc(fptr))!= EOF)
{
printf("%c",ch);
}
fclose(fptr);
return 0;
}

37 / 100

What will be the output of the C program?

/*creating new file and writing data into a file*/
#include
int main()
{
FILE *fptr;
char name[40], name1[40];
fptr = fopen("record.txt", "r+");
if(fptr == NULL)
{
printf("File not exist");
exit(1);
}
printf("Enter your name: ");
gets(name);
fputs(name, fptr);
rewind(fptr);
fgets(name1, 40, fptr);
printf("Name: %s", name1);
fclose(fptr);
return 0;
}
/*say you give a name john*/

38 / 100

What will be the output of the C program?

/*The file datafile.txt is already exists.*/
/*This program uses the datafile.txt which contains the following data*/
/* Hai. This is quiz.com. */
#include
int main()
{
char ch;
FILE *fptr;
fptr = fopen("datafile.txt", "w+");
fclose(fptr);
fptr = fopen("datafile.txt", "r");
while((ch = fgetc(fptr))!= EOF)
{
printf("%c",ch);
}
fclose(fptr);
return 0;
}

39 / 100

What will be the output of the C program?

/*This program uses the datafile.txt which contains the following data*/
/* Hai. This is together.com. */
#include
int main()
{
char *str = "We are together.com";
fprintf(stdout, str);
return 0;
}

40 / 100

What will be the output of the C program?

#include
int main()
{
int f1, f2;
FILE *fp;
fp = fopen("datafile.txt", "w");
f1 = EOF;
f2 = feof(fp);
if(f1 == f2)
{
printf("EOF and feof(), both returns the same value");
}
else
{
printf("EOF and feof() both returns different values");
}
return 0;
}

41 / 100

What will be the output of the C program?

#include
int main()
{
char *str = "ZOHO";
while (*str)
{
putc(*str, stdout);
fputchar(*str);
printf("%c", *str);
str++;
}
return 0;
}

42 / 100

What will be the output of the C program?

/*This program uses two files*/
#include
int main()
{
char ch;
FILE *fptr1, *fptr2;
fp = fopen("datafile1.txt", "w");
fp = fopen("datafile2.txt", "w");
printf("Thank you.");
fclose(*fptr1, *fptr2);
return 0;
}

43 / 100

What will be the output of the C program?

/*This program uses the datafile.txt which contains the following data*/
/* Hai. This is quiz.com. */
#include
int main()
{
char ch;
FILE *fp;
fp = fopen("datafile.txt", "w");
while ((ch = fgetc(fp)) != EOF)
{
printf("%c", ch);
}
printf("Thank you.");
fclose(fp);
return 0;
}

44 / 100

What will be the otputof the program?
/*This program uses the datafile.txt which contains the following data*/
/* Hai. This is quiz.com. */

#include
int main()
{
unsigned char ch;
FILE *fp;
fp = fopen("datafile.txt", "r");
while ((ch = fgetc(fp)) != EOF)
{
printf("%c", ch);
}
printf(" Thank you.");
fclose(fp);
return 0;
}

45 / 100

fopen() function will not opens _____

46 / 100

What will be the output of the C program?

#include
int main()
{
EOF++;
printf("%d", EOF);
return 0;
}

47 / 100

What will be the output of the C program?

#include
int main()
{
int EOF = 0;
printf("%d", EOF);
return 0;
}

48 / 100

Choose a correct statement about C File Mode "w+".
FILE *p;
p=fopen("abc.txt","r+");

49 / 100

What are the C functions used to read or write a file in Text Mode.?

50 / 100

What is the syntax for writing a file in C using binary mode.?
FILE *fp;

51 / 100

Choose a correct statement about C file "R" mode operation using fopen.
fopen("abc.txt","r");

52 / 100

What is the need for closing a file in C language.?

53 / 100

Choose a correct statement about C file operation program.?
int main()
{
FILE *fp;
char ch;
fp=fopen("readme.txt","r");
while((ch=fgetc(fp)) != EOF)
{
printf("%c",ch);
}
}

54 / 100

Select a program which get input data from datafile and also send output into datafile ,it is called…

55 / 100

_____removes the named file, so that a subsequent attempt to open it will fail.

56 / 100

What does the following segment of code do? fprintf(fp, "Copying!");

57 / 100

What is the meant by 'a' in the following operation?

fp = fopen("hello.txt", "a");

58 / 100

Which is true about getc.getc returns?

59 / 100

A file written in text mode can be read back in binary mode.

60 / 100

A text stream is an ordered sequence of characters composed into lines, each line consisting of zero or more characters plus a terminating new-line character.

61 / 100

In fopen(), the open mode "wx" is sometimes preferred "w" because.
1) Use of wx is more efficient.
2) If w is used, old contents of file are erased and a new empty file is created. When wx is used, fopen() returns NULL if file already exists.

62 / 100

Which is data type of file pointer is

63 / 100

stderr, stdin, stdout are FILE pointers

64 / 100

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

65 / 100

Select a function which is used to write a string to a file

66 / 100

A data of the file is stored in _______

67 / 100

What is the output of this program?

#include
int main(){
char c;
FILE *fp;
fp=fopen("demo.txt","a+"); // demo.txt : hello you are reading a file
fprintf(fp," demo");
fclose(fp);
fp=fopen("myfile.txt","r");

while((c=fgetc(fp))!=EOF)
printf("%c",c);
fclose(fp);
return 0;
}

68 / 100

What is the output of this program?

#include
int main(){
char c;
FILE *fp;
fp=fopen("demo.txt","r");
while((c=fgetc(fp))!=EOF)
printf("%c",c);
fclose(fp);
return 0;
}

69 / 100

What is the output of this program?

#include
int main(){
FILE *fp;
char *str;
fp=fopen("demo.txt","r");// demo.txt :you are a good programmer
while(fgets(str,6,fp)!=NULL)
puts(str);
fclose(fp);
return 0;
}

70 / 100

getc() returns EOF when

71 / 100

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

72 / 100

Which files will get closed through the fclose() in the following program?

void main()
{
FILE *fp, *ft;
fp = fopen("a.txt", "r");
ft = fopen("b.txt", "r");
fclose(fp,ft);
}

73 / 100

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

74 / 100

Which is true?

75 / 100

What is the return value of putchar()?

76 / 100

It is not possible to combine two or more file opening mode in open () method.

77 / 100

If there is any error while opening a file, fopen will return?

78 / 100

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

79 / 100

What does the following C code snippet mean?

int ungetc(int c, FILE *stream)

80 / 100

setvbuf() and setbuf() function controls buffering for the stream.

81 / 100

Select the right explanation for the following C code snippet.

int fgetpos(FILE *stream, fpos_t *s)

82 / 100

Which function will return the current file position for stream?

83 / 100

Which type of files cannot be opened using fopen()?

84 / 100

For binary files, a ___ must be appended to the mode string.

85 / 100

fseek() should be preferred over rewind() mainly because

86 / 100

FILE reserved word is?

87 / 100

FILE is of type ______

88 / 100

The first and second arguments of fopen() are

89 / 100

Which of the following mode argument is used to truncate?

90 / 100

Which of the following true about FILE *fp

91 / 100

what is the function of fputs()?

92 / 100

Choose the right statement for fscanf() and scanf()

93 / 100

fwrite() can be used only with files that are opened in binary mode.

94 / 100

What does tmpfile() returns when it could not create the file?

95 / 100

What is the function of FILE *tmpfile(void)?

96 / 100

_____removes the named file, so that a subsequent attempt to open it will fail.

97 / 100

fflush(NULL) flushes all ____________

98 / 100

If the mode includes b after the initial letter, what does it indicates?

99 / 100

What is the function of the mode ‘ w+’?

100 / 100

Which one of the following is correct syntax for opening a file.


Warning: Trying to access array offset on value of type null in /home/trafcc/techack.in/wp-content/themes/betheme/includes/content-single.php on line 286
admin

Leave a Reply

Your email address will not be published. Required fields are marked *