Computer Science, asked by BeulahDias916, 11 months ago

write a program using do while loop to compute the sum of the first 50 positive odd integers


tejasgupta: In which programmin language?
tejasgupta: Please answer me!

Answers

Answered by Rajkumarpatel89
7

Answer:

#include<iostream>

using namespace std;

int main()

{

   ///variable declaration

   int n,flag=0;

   int sum_odd=0;

   cout<<"enter the size of the n:";

   cin>>n;

   ///using do while loop

  do

  {

      if(n%2!=0)

      {

          flag++;

          sum_odd = sum_odd + n;

      }

  }

  while(n>0);

  n--;

  cout<<"sum of 50 odd integers:"<<sum_odd;

  cout<<"sum of total odd numbers:"<<flag;

  return 0;

}

Explanation:

Similar questions