Making your prgram repeat

This is a discussion on Making your prgram repeat within the C++ Programming forums, part of the General Programming Boards category; How do i make any simple or complex program repeat its self like the example program u give us Code: ...

  1. #1
    Registered User
    Join Date
    Jul 2005
    Posts
    1

    Making your prgram repeat

    How do i make any simple or complex program repeat its self like the example program u give us

    Code:
     #include <iostream>	
    
    using namespace std;
    		
    int main()                            // Most important part of the program!
    {
      int age;                            // Need a variable...
      
      cout<<"Please input your age: ";    // Asks for age
      cin>> age;                          // The input is put in age
      cin.ignore();                       // Throw away enter
      if ( age < 100 ) {                  // If the age is less than 100
         cout<<"You are pretty young!\n"; // Just to show you it works...
      }
      else if ( age == 100 ) {            // I use else just to show an example 
         cout<<"You are old\n";           // Just to show you it works...
      }
      else {
        cout<<"You are really old\n";     // Executed if no other statement is
      }
    
      cin.get();
    }
    How do i make it reapeat again at the end so it doesnt close the 2nd time

  2. #2
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    You could use a loop. This site has a tutorial which'll teach you how to use the 3 types of loops in C++. http://www.cprogramming.com/tutorial/lesson3.html

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Repeat for part of string
    By bertazoid in forum C Programming
    Replies: 6
    Last Post: 10-26-2008, 05:06 PM
  2. Making great graphics
    By MadCow257 in forum Game Programming
    Replies: 1
    Last Post: 02-20-2006, 10:59 PM
  3. Making an Algorithm repeat itself
    By mvd1212 in forum C Programming
    Replies: 13
    Last Post: 12-02-2005, 06:10 PM
  4. Help with trying to kill repeat function
    By otchster in forum C Programming
    Replies: 13
    Last Post: 10-25-2005, 09:02 PM
  5. About Unix Programming - Making a career desision
    By null in forum C Programming
    Replies: 0
    Last Post: 10-14-2001, 07:37 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21