SUM USING FOR LOOP SUM OF ALL EVEN NUMBERS
#include <iostream>
using namespace std;
int main()
{ int sum = 0;
for( int i = 0; i<=90; i= i+2 ){
cout<<i<<endl;
// cout<<i<<endl;
sum = sum + (i);
}
cout<<"the sum is "<<sum<<endl;
return 0;
}
#include <iostream>
using namespace std;
int main()
{ int sum = 0;
for( int i = 0; i<=90; i= i+2 ){
cout<<i<<endl;
// cout<<i<<endl;
sum = sum + (i);
}
cout<<"the sum is "<<sum<<endl;
return 0;
}
Comments
Post a Comment