Thread: Need HelP For a Programm

  1. #1
    Registered User
    Join Date
    Dec 2017
    Posts
    7

    Need HelP For a Programm

    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.
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    3,675
    Your formatting needs work. Mixing tabs and spaces make your code look bad.

    Code:
    goto MenGal; //// Backward Label
    goto is normally not considered good for newbie coders to use.


    Code:
    for (star=1; star <= rows; star++) {
    I try to avoid "<=" in for statements

    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.
    Code:
    for (star=0; star < rows; star++) {
    Note: Since you failed to ask a specific question; I can give you no more help.

    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

  3. #3
    Registered User
    Join Date
    May 2009
    Posts
    3,675
    Code:
    int number_of_stars = 6;
    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:
    #define NUMBER_OF_STARS 6
    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

  4. #4
    Registered User
    Join Date
    Apr 2017
    Location
    Quetzaltenango
    Posts
    82
    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().

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How can i run a programm ?
    By Shirali in forum C++ Programming
    Replies: 3
    Last Post: 03-29-2009, 02:05 AM
  2. Plz help me C programm
    By ferroz1 in forum C Programming
    Replies: 7
    Last Post: 05-10-2008, 06:55 AM
  3. first C++ programm..
    By datainjector in forum C++ Programming
    Replies: 3
    Last Post: 12-08-2002, 08:30 PM
  4. help me with this programm
    By a.christodoulou in forum C++ Programming
    Replies: 1
    Last Post: 11-30-2002, 04:50 AM
  5. C:How to programm
    By datainjector in forum C Programming
    Replies: 2
    Last Post: 09-01-2002, 07:35 PM

Tags for this Thread