Hey Guys I'm Trying to Make a Program in Which 5 Cases if user input 1 then IDE print Stars if enter 2 IDE print numbers in Pyramid Shap,
I have Little bit Confusion So Please Help me with Attached Code.
Hey Guys I'm Trying to Make a Program in Which 5 Cases if user input 1 then IDE print Stars if enter 2 IDE print numbers in Pyramid Shap,
I have Little bit Confusion So Please Help me with Attached Code.
Your formatting needs work. Mixing tabs and spaces make your code look bad.
goto is normally not considered good for newbie coders to use.Code:goto MenGal; //// Backward Label
I try to avoid "<=" in for statementsCode:for (star=1; star <= rows; star++) {
So, I might re-write your code like below.
Edit: I also find it better to start with zero if it makes no difference in the code.
Note: Since you failed to ask a specific question; I can give you no more help.Code:for (star=0; star < rows; star++) {
Tim S.
"...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson
It looks like you are trying to use number_of_stars as both a variable and a constant; choose one and if you want it to be a constant use something like.Code:int number_of_stars = 6;
Tim S.Code:#define NUMBER_OF_STARS 6
"...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson
You did not define rows before assigning it in your for loop in case 1. The (inner) breaks in cases 1-4 only break out of the for loops, not the switch, so they all fall through to the next case. You probably meant getchar() in place of getch() but it never executes anyway because of the goto. The argument to exit should be EXIT_SUCCESS or EXIT_FAILURE for which you need to #include <stdlib.h> or you could just return -5 instead of calling exit().