#include <iostream>using std::cout;using std::cin;using std::endl;int main(){ int number, counter = 0; float average = 0; cout << "Enter the number: "; cin >> number; //1) for(int i = 0; i <= number; i++) { average += i; } average /= (number + 1); //2) for(int i = 0; i <= number; i++) { if(i % 2 == 0) //Если чётное { counter++; } } cout << "Average = " << average << endl; cout << "The amount of even elements: " << counter << endl; return 0;}
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main()
{
int number, counter = 0;
float average = 0;
cout << "Enter the number: ";
cin >> number;
//1)
for(int i = 0; i <= number; i++)
{
average += i;
}
average /= (number + 1);
//2)
for(int i = 0; i <= number; i++)
{
if(i % 2 == 0) //Если чётное
{
counter++;
}
}
cout << "Average = " << average << endl;
cout << "The amount of even elements: " << counter << endl;
return 0;
}