Ex.1
#include <iostream>
using namespace std;
int n, s = 0;
int main(){
cout << "n=";
cin >> n;
for (int i = 2; i <= n;i+=2){
s += i;
}
cout << "s=" << s;
return 0;
}
Ex.2
#include <iostream>
using namespace std;
int a,b;
int main(){
cout << "a=";
cin >> a;
cout << "b=";
cin >> b;
for (int i = a; i <= b;i++){
cout << i << " ";
}
return 0;
}
Ex.3
#include <iostream>
using namespace std;
int a,b, s = 0;
int main(){
cout << "a=";
cin >> a;
cout << "b=";
cin >> b;
for (int i = a; i <= b;i++){
s += i;
}
cout << "s=" << s;
return 0;
}