1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to completely end a program if some condition given holds true?

Discussion in 'C' started by faizankhan666, Dec 31, 2006.

  1. faizankhan666

    faizankhan666 New Member

    Joined:
    Dec 31, 2006
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    For example if some variable lets say..a is greater than 10 then program should close....

    i.e
    "press any key to continue" message appears.
     
  2. NewsBot

    NewsBot New Member

    Joined:
    Dec 2, 2008
    Messages:
    1,267
    Likes Received:
    2
    Trophy Points:
    0
    Use the exit(0) function to terminate the program
     
  3. rohitphulsunge

    rohitphulsunge New Member

    Joined:
    Jan 11, 2010
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Nagpur, Maharashtra, India
    Rohit Phulsunge says-


    //Some lines of code
    ..........
    if(a>10)
    {
    printf("\n Press any key to continue");
    getch();
    exit(0);
    }
    ............
     
  4. imported_crmahato

    imported_crmahato New Member

    Joined:
    Mar 9, 2010
    Messages:
    23
    Likes Received:
    0
    Trophy Points:
    0
    yes exit(0);
    this will take you to end of program:)
     

Share This Page