Skip to content

Instantly share code, notes, and snippets.

@m1irka
Last active October 24, 2024 10:34
Show Gist options
  • Select an option

  • Save m1irka/1e19b8bd37408d7b10ddda288c8d7146 to your computer and use it in GitHub Desktop.

Select an option

Save m1irka/1e19b8bd37408d7b10ddda288c8d7146 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
int main() {
/*task 1
Знайти добуток усіх цілих чисел від а до 20 (значення а вводиться з клавіатури: 1
<= a <= 20).
*/
int x;
long long number = 1;
cout << "Enter the value of x (1 <= x <= 20): ";
cin >> x;
if (x < 1 || x > 20) {
cout << "Invalid x. It must be in the range 1 to 20." << endl;
}
for (int i = x; i <= 20; i++) {
number *= i;
}
cout << "Product of all integers from " << x << " to 20 equals: " << number << endl;
/*task 2
Написати програму, яка виводить на екран таблицю множення на k, де k - номер
варіанта. Наприклад, для 7-го варіанта:
7 x 2 = 14;
7 x 3 =21.
*/
int k;
cout << "Enter number: ";
cin >> k;
for (int i = 1; i <= 10; ++i) {
cout << k << " * " << i << " = " << k * i << endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment