Răspuns :
Răspuns:
Problema 4
#include <iostream>
using namespace std;
int main() {
int a, b, c;
int k = 0;
cout << "Introduceti primele 2 numere:\n";
cin >> a >> b;
cout << "Introduceti al treilea numar:\n";
cin >> c;
for (int i = a;i <= b; i++){
if (i % c == 0){
cout << i << ' ';
k++;
}
if (k == 5){
cout << "\n";
k = 0;
}
}
return 0;
}
Problema 5
#include <iostream>
using namespace std;
int main(){
int n, k;
int s = 0;
cout << "n=";
cin >> n;
cout << "k=";
cin >> k;
for (int i = 1; i <= n; i++){
if (i % k == 0){
s += i;
}
}
cout << "Suma numerelor mai mici ca " << n << " divizibile la " << k << " este:" << s;
cout << endl;
return 0;
}
Problema 6
#include <iostream>
using namespace std;
int main(){
int k;
cout << "k=";
cin >> k;
int i = k;
while (i >= 1){
if (i % 2 == 1 ){
cout << i << ' ';
}
i--;
}
return 0;
}
Explicație: