c - Semicolon - How is messing with this exercise -
I know that I should not have a semicolon after the loop. But I am learning and by mistake I have put one. And I wanted to know what was happening with my error, so the next time something like that happens, I know the source of the mistake.
In the code below, in this part of the code:
"triangular number = 0;
/ Pre>I accidentally inserted a semi colon " for (n = 1; n & lt; = number; ++ n)" loop when I execute the entire code This indicates the user to insert a number to calculate the triangle number, but the result with a semicolon is false. For example, when I insert 10, then the answer must be 55 Which semicolon error leads me to 56. I want to understand why 56.
The complete code is below:
< Pre>#include & lt; stdio.h> int main (zero) {int n, number, triangular number, counter (for counter = 1; counter & lt; = 5; counter ++) {Printf ("What triangle number do you want?"); Scanf ("% i", and number); for triangular number = 0; (n = 1; n
There is no suspension in the statement for the second
, Therefore code ;
runs number times!
You want:
for (n = 1; n
Comments
Post a Comment