In this program I am attempting to save each character that the user inputs into a do while loop that should count the number of spaces, new lines, and tabs.
When I run my program it doesn't end when '.', '!', or '?'
Why?
int characters, spaces, new_lines, tabs;
int user_input;
printf("Enter a sentence (end by '.' or '?' or '!'):");
do{
user_input = getchar();
if (user_input == ' ')
spaces++;
if (user_input == '\t')
tabs++;
if (user_input == '\n')
new_lines++;
} while((user_input != '.') || (user_input != '?') || (user_input != '!'));
printf("Number of space characters: %d", spaces);
printf("Number of new line characters: %d", new_lines);
printf("Number of tabs: %d", tabs);
return 0;
(user_input != '.') || (user_input != '?') || (user_input != '!').spaces,tabs, andnew_lineswithout initializing them. They can contain any garbage.Number of space characters: 223723574Number of new line characters: 32767Number of tabs: 1419576536. Turn on warnings, starting with-Wall.