My issue
i cant solve this question
My code
#include <stdio.h>
#include<ctype.h>
int main() {
// your code goes here
char ch;
int Lines = 0, Words = 0, Characters = 0, in_word = 0;
while ((ch = getchar()) != EOF) {
if (ch == '\n') {
Lines++;
} else {
Characters++;
}
if (isspace(ch)) {
in_word = 0;
} else if (!in_word) {
Words++;
in_word = 1;
}
}
if (Characters > 0 && ch != '\n') {
Lines++;
}
printf("Lines: %d\n", Lines);
printf("Words: %d\n", Words);
printf("Characters: %d\n", Characters);
return 0;
}
Learning course: Learn C Programming
Problem Link: https://www.codechef.com/learn/course/rcpit-programming-c/RCPITLPC12/problems/LJAJAG37