09-18-2011, 07:14 PM
How to write a summation in a sequence? C++ 2011-12
Code:
Here's what I got:
else if (choice == 3) {
int a=2;
int b=1;
int c=3;
int bound, sum, i;
cout << "Plese enter the upper bound of the summation you are looking for:" << endl;
cin>>bound;
if (bound< 0) cout << "Only Posiive Numbers are accepted\n\n";
else{
for(i=1;c<=sum;i++)
{
a=b;
b=c;
c=a+b;
sum=sum+c;
}
cout << sum << " is the summation of all numbers until " << bound << endl;
} }0300-9520262
Get solution in 24 hour |cpmputer & internet
mileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
