Write a C++ program which computes the sum of all even numbers between 1 and 99 using for loop. Write, scan and upload the program. Ensure the program has your registration number and signature.
#include<iostream>
using namespace std;
int main(){
int sum = 0 ;
for(int i=1; i<=99; i++){
if(i%2==0){
sum += i;
}
}
cout<<"The sum of all even numbers betweem 1 and 99 is: "<<sum<<endl;
}
Comments
Leave a comment