Write a C++ program which computes the sum of all even numbers between 1 and 99 using for loop.
#include<iostream>
using namespace std;
int main(){
int n,sum=0;
for(n=1;n<=99;n++){
if(n%2==0){
sum+=n;
}
}
cout<<"Sum of even numbers is: "<<sum;
}
Comments
Leave a comment