Thread: Termination

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    18

    Termination

    How do I write a line in a program that will terminate the program if the user enters E?
    for example they will be doing a math problem and it should go like this:
    34
    *
    2
    +
    9
    /
    3
    E (this should end the program than output the answer)
    so i just wanna know how do the termination part. Thank you.

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    8
    post what you have so far

  3. #3
    Registered User *pointer's Avatar
    Join Date
    Oct 2001
    Posts
    74
    Code:
    do {   /* Put the whole program in a do-while loop */
        char ch;  /* This can be whatever you want, the variable to hold your chosen character */
        .
        . /* Do your stuff */
        .
        ch = getchar();  /* Get the character from the user and assign it to ch */
    {
    while ( ch != 'E' || ch != 'e' );  /* If the character from the user is E or e, the loop will stop */
    printf( "%d", total );
    return 0; /* The program ends once the loop is exited */
    You get your character at the end of the loop so that you won't print it before the test.
    Last edited by *pointer; 10-14-2001 at 08:27 AM.
    pointer = NULL

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. null termination with str(n)cpy and strlen
    By jeanluca in forum C Programming
    Replies: 9
    Last Post: 06-22-2009, 03:52 PM
  2. zombie to exist after the termination of main program..
    By anilchowdhury in forum Linux Programming
    Replies: 0
    Last Post: 02-22-2008, 12:35 PM
  3. Replies: 4
    Last Post: 06-23-2006, 07:03 PM
  4. **///Re: Abnormal prg termination
    By jhsurti in forum C++ Programming
    Replies: 5
    Last Post: 01-07-2003, 02:33 AM
  5. abnormal program termination
    By ProLin in forum C++ Programming
    Replies: 2
    Last Post: 01-20-2002, 09:56 PM