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.
1
Expert's answer
2013-08-30T11:47:19-0400
#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;


system("PAUSE");
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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS