Here's my code:
#include
using namespace std;
int main()
{
int i = 0, max = 0, sum = 0;
char indicator = 'y';
cout<<"Please enter number 5: "; cin>>max;
cout<
for(i=1; i<=max; i++)
sum+=i;
cout<
<<"The Sum is = "<
cout<<"Do you wish to display the odd sum?"<
cout<<"Enter y for yes, (n to end)"; cin>>indicator;
if(indicator=='y')
{
for(i=1; max<=max; i=1+2)
sum=sum+i;
cout<
<<"The odd sum is = "<
}
cout<<"Okay Bye"<
return 0;
}
The answer for the 1st sum is correct 15
But the Odd sum answer should be 9 and it's aint displaying and wrong answer.
2007-01-25
19:17:40
·
5 answers
·
asked by
capphire
2
in
Computers & Internet
➔ Programming & Design