Thread: simple question>>

  1. #1
    Registered User
    Join Date
    May 2006
    Location
    in your head
    Posts
    49

    simple question>>

    hello there i got a very simple question:

    Code:
    #include <iostream>
    
    
    using namespace std;
    
    int main(void)
    {
    
    int count;
    
    for(count=1; count<=10; count++){
    cout << count << endl;
    
    }
    cout << endl;
    cout << "The total is "<< (1+2+3+4+5+6+7+8+9+10) << endl;
    cin.get();
    return 0;
    }
    The question is how can i add the looped numbers automatically..? any help there....?thanks....

  2. #2
    Registered User
    Join Date
    Jul 2006
    Posts
    14
    Simple

    Code:
    #include <iostream>
    
    
    using namespace std;
    
    int main(void)
    {
    
    int count;
    int total = 0;
    
    for(count=1; count<=10; count++){
    cout << count << endl;
    total += count;
    
    }
    cout << endl;
    //cout << "The total is "<< (1+2+3+4+5+6+7+8+9+10) << endl;
    cout << "The total is " << total << endl;
    cin.get();
    return 0;
    }

  3. #3
    Registered User
    Join Date
    May 2006
    Location
    in your head
    Posts
    49
    thank you very much....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. creating very simple text editor using c
    By if13121 in forum C Programming
    Replies: 9
    Last Post: 10-19-2010, 05:26 PM
  2. Simple message encryption
    By Vicious in forum C++ Programming
    Replies: 10
    Last Post: 11-07-2004, 11:48 PM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. Simple simple program
    By Ryback in forum C++ Programming
    Replies: 10
    Last Post: 09-09-2004, 05:48 AM
  5. Need help with simple DAQ program
    By canada-paul in forum C++ Programming
    Replies: 12
    Last Post: 03-15-2002, 08:52 AM