77 945
Assignments Done
Successfully Done
In August 2019

Answer to Question #34666 in C++ for ali minhas

Question #34666
how to find square of even numbers and cube of odd numbers b\w 1 to 20? plz give me answer.
Expert's answer
#include <iostream>

using namespace std;

int main()
double sum1(0);
double sum2(0);

for (int i=1;i<21;++i)
if (i%2 == 0)sum1+=i*i;
else sum2+=i*i*i;

cout<<"square of even : "<<sum1<<endl;
cout<<"cube of odd : "<<sum2<<endl;

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!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions