Answer to Question #197604 in C++ for aly

Question #197604

Using a do while loop, write a program in C++ that can display all the odd numbers from 25 to 10 inclusively. The program should be able to display the sum of the numbers as well.


1
Expert's answer
2021-05-23T14:39:11-0400
#include <iostream>


using namespace std;


int main()
{
    int i=25;
    int sum=0;
    do{
        if (i%2 !=0){
            cout<<i<<endl;
            sum=sum+i;
        }
        i--;
    }
    while(i>=10);
    cout<<"\nSum: "<<sum;


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog