Answer to Question #257968 in C++ for Kelvin Tito

Question #257968

 Write a C++ program which computes the sum of all even numbers between 1 and 99 using for loop.


1
Expert's answer
2021-10-28T07:56:06-0400
#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;
	
	
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS