- This topic is empty.
Viewing 1 post (of 1 total)
Viewing 1 post (of 1 total)
- You must be logged in to reply to this topic.
IT, Programming, & Web Development › Forums › CS50’s Introduction to Computer Science by Harvard University on Edx › Week 2: [Arrays] – Functions, Variable and Scope, Debugging, Arrays, and Command Line Arguments › Readability lab: Counting number of lines
Tagged: arrays, c, counter, global variable, if statement, increment, iteration, local variable, loop, readability, while loops
Intend to count no. of .,!, ? in the entered text by the user that will help count no. of lines.
#include <stdio.h>
#include <cs50.h>
#include <string.h>
int main(void)
{
string enterword = get_string("input");
int t = strlen(enterword);
printf("%i\n", t);
for(int i = 0; i<= t; i++)
{
int counter = 0;
if (enterword == '.' or '!' or '?')
counter = counter + 1;
}
printf("no. of lines:",counter);
}
Not compiling. The error message showing ‘missing a closing parenthesis on line 13 of readability.c.’ There is a closing parenthesis on line 13 though.
Reply
https://edstem.org/us/courses/176/discussion/975312?answer=2208999[learn_press_profile]