how to write c++ programme of these questions (for loop)
Attachments:
Answers
Answered by
1
Answer:
#include <iostream>
using namespace std;
int sum = 0 , ec = 0;
double average;
int main() {
for(int i = 1; i <= 49; i++){
if(i%2 == 0){
cout << i << " ";
sum = sum + i;
ec++;
}
cout << "The sum of even numbers between 1 and 49 is " << sum;
cout << "The average is " << (sum/ec);
}
return 0;
}
Explanation:
Similar questions