Computer Science, asked by cleverchidiriro, 8 months ago

Write a program in C++ that calculates and displays the sums of squares of odd and even numbers separately in the range 0 to 50 inclusive.

Answers

Answered by MrVikrant
1

Answer:

Explanation:

/** Author : Vikrant Verma **/

#include <iostream>

using namespace std;

int main()

{

   int i, even_sqr_sum = 0, odd_sqr_sum = 0;

   

   for(i = 0; i <= 50; i++)

   {

       if(i % 2 == 0)

       {

           even_sqr_sum = even_sqr_sum + (i * i);

       }

       else

       {

           odd_sqr_sum = odd_sqr_sum + ( i * i);

       }

   }

   cout<<"sum of squares of even numbers from 0 to 50 : " << even_sqr_sum << endl;

   cout<<"sum of squares of odd numbers from 0 to 50 : " << odd_sqr_sum << endl;

   return 0;

}

Similar questions