Computer Science, asked by buttfiza66, 3 months ago

Write a c++ program to calculate the sum of odd numbers from 5-20

Answers

Answered by anindyaadhikari13
3

Answer:

This is the required C++ program for the question.

#include <iostream>

using namespace std;

int main() {

int s=0,i=5;

for(;i<=20;i+=2)

s+=i;

cout << "Sum is: " << s;

return 0;

}

Algorithm:

  1. START.
  2. Initialise s = 0.
  3. Iterate a loop in range i = 5 to 20.
  4. Add the value of i to s.
  5. Increment the value of i by 2.
  6. Display the value of s.
  7. STOP.

See the attachment for output .

Attachments:
Similar questions