Do While Loop in C++

Download
Download is available until [expire_date]
  • Version
  • Download 14
  • File Size 1.33 KB
  • File Count 1
  • Create Date April 18, 2016
  • Last Updated April 18, 2016

Do While Loop in C++

Do While Loop in C++

This is program in c++ that demonstrate how do while loop functions in c++. The user will asked how many numbers he/she wants to enter, then program will compute the sum of the numbers entered by the user.

Source code:

#include < iostream >
using namespace std;

int main()
{
    int numbersToCompute, x=0;
    double sum=0, numValue;

cout << "enter number of numbers to compute" << endl;
cin>>numbersToCompute;
    do
    {
        cout << "enter value: " << endl;
        cin>>numValue;
        sum=sum+numValue;

        x++;
    }while(x < numbersToCompute);


cout << "sum of "<< numbersToCompute <<" numbers = " << sum << endl;
    return 0;
}
, , , , , ,

Post navigation

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.