Data Structures and Algorithms Discussion Board
September 10, 2010, 02:24:59 PM *
Welcome, Guest. Please login or register.
Login with username, password and session length
News: Looking for a reliable webhosting provider? Read HostGator review to find 7 arguments in support of HostGator.
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Do while loop  (Read 1583 times)
chichi
Newbie
*

Rating: 0
Offline Offline

Posts: 7


« on: March 15, 2009, 10:36:14 AM »

How do i write a program in C++ using do while loop to count from -10 to 10?
Logged
Denis
Newbie
*

Rating: 0
Offline Offline

Posts: 21


« Reply #1 on: March 15, 2009, 10:52:08 AM »

Try this:

Code:
int i;
i = -10;
do {
i++;
} while (i <= 10);

If you would like to run it, the whole program is:

Code:
#include <iostream>

int main()
{
int i;
i = -10;
do {
std::cout << i << std::endl;
i++;
} while (i <= 10);
system("PAUSE");
return 0;
}

Read more: Control Structures
Logged
chichi
Newbie
*

Rating: 0
Offline Offline

Posts: 7


« Reply #2 on: March 15, 2009, 11:52:13 AM »

Thank you Denis!
Logged
Algolist.net Editor
Administrator
Newbie
*****

Rating: 0
Offline Offline

Posts: 8


« Reply #3 on: March 16, 2009, 11:20:52 AM »

Topic has been split, see A C++ Program.
« Last Edit: November 21, 2009, 04:21:37 AM by Algolist.net Editor » Logged
Pages: [1]
  Print  
 
Jump to: