Tuesday, May 5, 2009

PROGRAM TO CONVERT A GIVEN NUMERICAL TO ALPHABETIC NUMBER

#include
#include
#include
int count(int n);
int rev(int n);
void main()
{
int i,j,n;
clrscr();
printf("Enter any number\n");
scanf("%d",&n);
j=rev(n);
while(j>0)
{
i=j%10;
j=j/10;
switch(i)
{
case 0:printf(" ZERO ");
break;
case 1:printf(" ONE ");
break;
case 2:printf(" TWO ");
break;
case 3:printf(" THREE ");
break;
case 4:printf(" FOUR ");
break;
case 5:printf(" FIVE ");
break;
case 6:printf(" SIX ");
break;
case 7:printf(" SEVEN ");
break;
case 8:printf(" EIGHT ");
break;
case 9:printf(" NINE ");
break;
}
}
getch();
}


int count(int n)
{
int count =0;
while (n>0)
{ n=n/10;
count ++;
}
return count;
}



int rev(int n)
{
int i,sum=0;
int l=count(n);
l--;
while(n>0)
{
i=n%10;
n=n/10;
sum+=(i*pow(10,l));
l--;
}
return sum;
}

No comments:

Post a Comment