# Tag Info

3

you want to keep asking the user about height if n is smaller than 1 or larger than 8 right ? check your code, the way you're writing it ,the program is gonna keep asking for height as long as n is smaller than nine ! ( which is not what you want). therefore the solution is change "while (n < 9)" to "while (n < 1 || n > 8)"

2

Assuming the error you are getting is not related to a linking error, which is common, then the error I assume you are getting is loop_check.c:14:15: warning: '&&' within '||' [-Wlogical-op-parentheses] }while(C< 0 && C < 999999999999999 || C < 0 && C > 9999999999999999); ~~~~~^~~~~~~~~~~~~~~~~~~~~~ ~~ ...

1

I'm not entirely sure about the logic of your conditions but putting the and (&&) conditions in brackets () should fix it. This is what you have: while(C< 0 && C < 999999999999999 || C < 0 && C > 9999999999999999); change to: while((C < 0 && C < 999999999999999) || (C < 0 && C > ...

1

Your while loop does not end up EDIT: (Thanks to SuperNovaCoder for your intervention) The problem is that equality must be achieved ie the conditions must be >= EDIT1: while(cent_amount>=0) should be: while(cent_amount>0) To allow the loop to finish

1

Your code is actually doing what you told it to, but you told it to print out the number of bottles before it exited the for-loop. A simple fix is to put the printf outside the for-loop. If you still have issues/questions, comment below.

1

The declaration of your main function needs to be as so: int main(void) { ...code... } Notice the positions of curly braces relative to the declaration and the lack of semi-colons.

1

My solution is very similar to yours. The printf("%s", " "); could be changed to printf(" ");. You could (not sure if you should) combine the two for-loops for(int j = 0; j < h-i-1; j++) //incrementing for j { printf("%s", " "); //aligning right. } for(int k = 0; k < i+2; k++) { printf("#"); //printing the hashes ...

1

Your analysis is correct. Perhaps you might want to review class materials on the difference between while loops and do/while loops? A do/while loop is guaranteed to run at lease once because the test is done after the loop executes. A while loop (which is different from a do/while loop) may not execute the loop at all because the test is done before ...

1

Look at the test in the while loop: while (hight < 0 && hight > 23); The while loop will repeat when the test condition is true. So with that in mind, can you tell me any number that can be less than zero AND greater than 23 at the same time? If this answers your question, please click on the check to accept. Let's keep up on forum ...

1

Simple problem. You put a semicolon in int main(void); The correct structure is: int main(void) { // code goes between curly braces } You also have a declaration statement, int n; before the first brace. The compiler assumes you mostly know what you are doing, so the two lines with main and int n which end in semicolons look like a function signature ...

Only top voted, non community-wiki answers of a minimum length are eligible