Given the sum s find the smallest 5 digit number whose sum of digits is equal to s in c
Answers
Answered by
0
1- take input value of s
make variable a,b,c,d,e
where a=x%10000;
b=x%1000;
c=x%100;
d=x%10;
e=x%1;
then make var sum where
sum=a+b+c+d+e;
after that use for loop
for (x=10000 ;x<=s ; x++)
{
if (sum== s)
{
printf "no. is $x";
exit;
}
}
Similar questions