Hi,
if the user types 123.88 i multiply it with 100 in order to take 12388 and then divide the number by ten in order to take every digit.
What if the user types 4 or 45,then my program is going to multiply them again with 100 and i'm going to have 400 , 4500
What shall i do then?
I do:
Code:
#include <stdio.h>
#include <stdlib.h>
int main() {
float d;
int cnt = 1; //counts the number of digits the number has
scanf("%f",&d);
d= d* 100; //multiply it by 100 cause the user can input a number with two decimal digits
int k = (d / 10);
while( k != 0 ) {
cnt = (cnt + 1);
k = (k / 10);
}
}
What shall i do ?