Set of multiple choice questions for programming with P15 prize

Programming is a discipline that attracts many young people interested. Not only that job opportunities after graduation with this job are extremely open. So, if you love programming, you should not ignore the following quiz series of Network Administrator.

  1. Question 1. Choose the correct answer
     FILE * f = fopen ('FL.txt', 'r'); 

    int n = 7; fprintf (f, '% d', n);
    1. The code causes an error
    2. The code is not error
    3. This code will write 7 to the 'FL.txt' file.
    4. This code will read a value from file 'FL.txt' into variable n
  2. Question 2. Declaring the function reading a text file into an array of integers, choose the correct declaration:
    1. void Read (char * fName, int a []);
    2. void Read (char * fName, int a);
    3. void Read (char * fName, int * a);
    4. void Read (char * fName, int * & a, int & n);
  3. Question 3. Suppose f is a binary file pointer. To read the word f for variable x of type int, we can use:
    1. fscanf (f, '% d', x);
    2. fread (& x, sizeof (int), 1, f);
    3. getw (f);
    4. 2 and 3 right
  4. Question 4. Select the best sentence in the following sentences:
    1. When reading a character with code 1A from a text file, C will read into a character with code -1
    2. When reading text files, both OD and OA characters will be read by C into 1 character with OA code
    3. When reading the character with the OD code from the text file, C will ignore it
    4. 1, 2 and 3 are all right
  5. Question 5. For declaring FILE * f1, * f2; int c; and the command:
     f1 = fopen ('source', 'rt'); f2 = fopen ('TARGET', 'wt'); while ((c = fgetc (f1))! = EOF) fputc (c, f2); 
    1. The 'source' file length is always smaller than the length of the 'TARGET' file.
    2. The file 'source' length equals the length of the file 'TARGET'.
    3. The 'source' file length is generally larger than the length of the 'TARGET' file.
    4. The length of the 'source' file will generally be greater than the length of a 1-byte 'TARGET' file.
  6. Question 6. Which of the following functions is only used to read 1 character from a file:
    1. getch ();
    2. fscanf ();
    3. fgetc ();
    4. scanf ();
  7. Question 7. Which of the following functions is only used to write one character to a file:
    1. putch ();
    2. puts ();

    3. fputs ();
    4. fputc ();
  8. Question 8. Which of the following functions is used to write 1 string of characters to the file:
    1. putch ();
    2. fputc ();
    3. fputs ();
    4. puts ();
  9. Question 9. Suppose the DATA file contains 5 bytes: '70, 26, 13, 10, 44 '. Give the command. What is the result of the above program?
     FILE * f; 

    char ch; f = fopen ('DATA', 'r');

    while (! feof (f)) {ch = fgetc (f); printf('%c',ch);}; printf ('% c', ch);}; fclose (f);
    1. '70, 26,13,13,10,44 '.
    2. '70, 26,13,10,44 '.
    3. '70, 26,10,44 '.
    4. The script failed
  10. Question 10. Give the DATA binary file containing the sequence of adjacent structures L struct T {.} x, and f is the file pointer to DATA. Choose the best sentence in the following sentences:
    1. The command fseek (f, 10, SEEK_END) locates the file pointer to the 10th byte in the file
    2. The command fseek (f, 10, SEEK_END); Locate the cursor to the end of the file
    3. Assuming the file has n structures, the command fseek (f, n, SEEK_SET) will place the pointer to the final structure of the file.
    4. Assuming the file has n structures, the command fseek (f, n, SEEK_CUR); will not change the cursor position of the file
Update 24 May 2019
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile