Computer Science, asked by hussain4829, 1 year ago

write a c++ program to find the sum of first 10 odd numbers​

Answers

Answered by Rajkumarpatel89
3

Answer:

#include<iostream>

using namespace std;

int main()

{

   ///variable declaration

   int arr[20];

   int n;

   int sum_odd=0,sum_even=0;

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

   cin>>n;

   for(int i=0; i<=n; i++)

   {

       if(i%2!=0)

       {

           sum_odd = sum_odd+i;

       }

       if(i%2==0)

       {

           sum_even = sum_even+i;

       }

   }

   cout<<"sum of 10 odd numbers:"<<sum_odd;

   cout<<"sum of 10 even numbers:"<<sum_even;

   return 0;

}

Explanation:

Similar questions