Печать
Категория: Амалҳо бо ададҳои бутун
Просмотров: 1488

Integer7. Адади дурақама дода шудааст. Сумма ва ҳосили зарби рақамҳои он ёфта шавад.

Ҳал дар Python 3:

import random

N = random.randrange(10,100)
print("N = ", N)
d1 = int(N/10)
d0 = N%10
print("Tens: ", d1)
print("Units: ", d0)
print("Sum: ", d1+d0)
print("Product: ", d1*d0)

Ҳал дар C++:

#include <iostream>
using namespace std;
int main(){
int n, f, s;
cout << "Enter the number N: ";
cin >> n;
f = int(n/10);
s = n%10;
cout << "Sum of the digits: " << f+s << endl;
cout << "Product of the digits: " << f*s;
return 0;
}