-4
I need help to write numbers in full from 0 to 10000. I could only write up to 1500, as you can see below:
#include <stdio. h>
int main () {
float a;
printf ("Digite um numero de 1 a 1500:\n");
scanf ("%f", &a);
if (a>1500)
printf ("O numero deve ser menor do que 1500\n");
else
{
if (a>=1000)
{
printf ("mil ");
a=a-1000;
}
if (a>=100)
if (a>=900)
{
printf ("novecentos ");
a=a-900;
}
else if (a>=800)
{
printf ("oitocentos ");
a=a-800;
}
else if (a>=700)
{
printf ("setecentos ");
a=a-700;
}
else if (a>=600)
{
printf ("seiscentos ");
a=a-600;
}
else if (a>=500)
{
printf ("quinhentos ");
a=a-500;
}
else if (a>=400)
{
printf ("quatrocentos ");
a=a-400;
}
else if (a>=300)
{
printf ("trezentos ");
a=a-300;
}
else if (a>=200)
{
printf ("duzentos ");
a=a-200;
}
else if (a>=100)
{
printf ("cem ");
a=a-100;
}
if (a>=10)
if (a>=90)
{
printf ("noventa ");
a=a-90;
}
else if (a>=80)
{
printf ("oitenta ");
a=a-80;
}
else if (a>=70)
{
printf ("setenta ");
a=a-70;
}
else if (a>=60)
{
printf ("sessenta ");
a=a-60;
}
else if (a>=50)
{
printf ("cinquenta ");
a=a-50;
}
else if (a>=40)
{
printf ("quarenta ");
a=a-40;
}
else if (a>=30)
{
printf ("trinta ");
a=a-30;
}
else if (a>=20)
{
printf ("vinte ");
a=a-20;
}
else if (a>=10)
{
printf ("dez ");
a=a-10;
}
if (a>=1)
if (a>=9)
{
printf ("nove ");
a=a-9;
}
else if (a>=8)
{
printf ("oito ");
a=a-8;
}
else if (a>=7)
{
printf ("sete ");
a=a-7;
}
else if (a>=6)
{
printf ("seis ");
a=a-6;
}
else if (a>=5)
{
printf ("cinco ");
a=a-5;
}
else if (a>=4)
{
printf ("quatro ");
a=a-4;
}
else if (a>=3)
{
printf ("tres ");
a=a-3;
}
else if (a>=2)
{
printf ("dois ");
a=a-2;
}
else if (a>=1)
{
printf ("um ");
a=a-1;
}
if (a>0,00)
if (a>=0,90)
{
printf ("noventa ");
a=a-0,90;
}
else if (a>=0,80)
{
printf ("oitenta ");
a=a-0,80;
}
else if (a>=0,70)
{
printf ("setenta ");
a=a-0,70;
}
else if (a>=0,60)
{
printf ("sessenta ");
a=a-0,60;
}
else if (a>=0,50)
{
printf ("cinquenta ");
a=a-0,50;
}
else if (a>=0,40)
{
printf ("quarenta ");
a=a-0,40;
}
else if (a>=0,30)
{
printf ("trinta ");
a=a-0,30;
}
else if (a>=0,20)
{
printf ("vinte ");
a=a-0,20;
}
else if (a>=0,10)
{
printf ("dez ");
a=a-0,10;
}
}
fflush (stdin);
getchar ();
return 0;
}
Welcome to Stackoverflow. What have you tried? Once you answer, you can see your question and help yourself. If you can edit your question to include your attempt it would be very nice.
– Naslausky
I found something in [tag:C] here on [en.so] see How to write a number in full in C Language?
– gleisin-dev