Write a loop that generate even numbers such as 2,4,6, ....., 18, 20.
sum those numbers
using c++
#include <iostream>
using namespace std;
int main(){
int sum=0;
for(int i=2;i<=20;i=i+2){
sum=sum+i;
cout<<i<<" ";
}cout<<endl;
cout<<"Sum: "<<sum<<endl;
}
Get Answers For Free
Most questions answered within 1 hours.