# ASCII Progress Bar

I think my code is properly ok, but it’s showing runtine error everytime

``````
usr = float(input()).__floor__()
# print(usr)
if 0 <= usr <= 100:
if usr < 10:
print("[", "."*10, "]", sep="", end=" ")

elif 10 < usr < 20:
print("[+", "." *9, "]", sep="", end=" ")

elif 20 < usr < 30:
print("[++", "." *8, "]", sep="", end=" ")

elif 30 < usr < 40:
print("[+++", "." *7, "]", sep="", end=" ")

elif 40 < usr < 50:
print("[++++", "." *6, "]", sep="", end=" ")

elif 50 < usr < 60:
print("[+++++", "." * 5, "]", sep="", end=" ")

elif 60 < usr < 70:
print("[++++++", "." * 4, "]", sep="", end=" ")

elif 70 < usr < 80:
print("[+++++++", "." * 3, "]", sep="", end=" ")

elif 80 < usr < 90:
print("[++++++++", "." * 2, "]", sep="", end=" ")

elif 90 < usr < 100:
print("[+++++++++", "." * 1, "]", sep="", end=" ")

elif usr == 100:
print("[++++++++++", "." * 0, "]", sep="", end=" ")

print(usr,"%", sep="")

else:
exit()

``````

@hjr265

``````# Coded by SpiderX

usr = int(float(input()))
# print(usr)
if 0 <= usr <= 100:
print("[", "+" * (usr // 10), "." * (10 - (usr // 10)), "]", sep="", end=" ")
print(round(usr), "%", sep="")
``````

This Worked Finally

``````#include <stdio.h>
#include <math.h>

int main(void)
{
float p;
scanf("%f", &p);
int num = (int)(p / 10.00);

print("[");

for (int i = 0; i < num; i++)
{
printf("+");
}
for (int i = 0; i < 10 - num; i++)
{
printf(".");
}
printf("]");

printf(" %i%%", (int)p);
return 0;
}
``````

why this is not getting accepted?

1 Like

Try using type `double` for `p`.

``````float p;
``````

Use:

``````double p;
``````

Also, make sure you update your `scanf` function call accordingly.