30/09/2018, 16:02

Poll: Kiểm tra kiến thức C - 1.14

Các bạn thảo luận đáp án nhé, bài test lấy từ http://www.indiabix.com/online-test/c-programming-test/11

14.Which of the following statement is correct about the program?

#include<stdio.h>

int main()
{
    FILE *fp;
    char ch;
    int i=1;
    fp = fopen("myfile.c", "r");
    while((ch=getc(fp))!=EOF)
    {
        if(ch == '
')
            i++;
    }
    fclose(fp);
    return 0;
}
  • A. The code counts number of characters in the file
  • B. The code counts number of words in the file
  • C. The code counts number of blank lines in the file
  • D. The code counts number of lines in the file
Đỗ Trung Quân viết 18:04 ngày 30/09/2018

D: This program counts the number of lines in the file myfile.c by counting the character ‘\n’ in that file.

Bài liên quan
0