Given one integer N, for each digit from the end of N, print a line of stars which has number of stars equal to that digit C++
Example Input: 2863
Example Output:
***
******
********
**
my code work in inputs like 12345,..,etc. but not work in 2863 !! i dont why and how can i edit my code to handle this problem !
#include <stdio.h>
int main()
{
int b,d,j=0,num,num1,length=0,length1,x[100];
float a,c;
scanf("%d",&num);
num1=num;
while(num!=0){
num/=10;
length++;
}
length1=length;
for(int i=0; length!=0; i++){
a=(float)num1/10;
b=num1/10;
c=a-(float)b;
d=c*10;
x[i]=d;
length--;
num1=b;printf("%d\n",d);
}
while(length1!=0){
while(x[j]!=0){
printf("*");
x[j]--;
}
length1--;
j++;
printf("\n");
}
}