8. The product of the digits of a three-digit number - solution
#include <stdio.h>
#include <stdlib.h>
/*Enter a three-digit number, then determine the product of the digits*/
int main()
{
int number,s,d,j,product;
printf("Enter a three-digit number\n");
scanf("%d", &number);//789
/*It is necessary to determine the figures first*/
s = number/100; //s=789/100=7, Rounds to the first smaller integer, because the type is int
d = number% 100 / 10; //d=(789%100)/10=89/10=8, 789 % 100 gives the remainder of dividing these two numbers which is 89
j = number% 10; //j=789%10=9, because the remainder of dividing 789 and 10 is 9
product=s*d*j; //7*8*9=504
printf("proizvod=%d",product);
return 0;
}
#include <stdlib.h>
/*Enter a three-digit number, then determine the product of the digits*/
int main()
{
int number,s,d,j,product;
printf("Enter a three-digit number\n");
scanf("%d", &number);//789
/*It is necessary to determine the figures first*/
s = number/100; //s=789/100=7, Rounds to the first smaller integer, because the type is int
d = number% 100 / 10; //d=(789%100)/10=89/10=8, 789 % 100 gives the remainder of dividing these two numbers which is 89
j = number% 10; //j=789%10=9, because the remainder of dividing 789 and 10 is 9
product=s*d*j; //7*8*9=504
printf("proizvod=%d",product);
return 0;
}