Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I made a program to convert numbers from integer to english in Indian Number format, I am unsure how would I convert this to international system, Any suggestions ??

C++
#include<stdio.h>
#include<conio.h>

void convert(long,char[]);

char *one[]={" "," one"," two"," three"," four"," five"," six"," seven","eight"," Nine"," ten"," eleven"," twelve"," thirteen"," fourteen","fifteen"," sixteen"," seventeen"," eighteen"," nineteen"};
char *ten[]={" "," "," twenty"," thirty"," forty"," fifty"," sixty","seventy"," eighty"," ninety"};


void main()
{
 long n;
 clrscr();
 printf("Enter any 9 digit no: ");
 scanf("%9ld",&n);
 if(n<=0)
                printf("Enter numbers greater than 0");
 else
 {
                  convert((n/10000000),"crore");
                  convert(((n/100000)%100),"lakh");
                  convert(((n/1000)%100),"thousand");
                  convert(((n/100)%10),"hundred");
                  convert((n%100)," ");
 }
 getch();
}


void convert(long n,char ch[])
{
 (n>19)?printf("%s %s ",ten[n/10],one[n%10]):printf("%s ",one[n]);
 if(n)printf("%s ",ch);
}


What I have tried:

I tried to change some values but i am unable to do so
Posted
Updated 8-Jan-21 23:15pm

1 solution

If you wrote that - pretty poor - code, you should be able to do this yourself: it's not a complex change.

If you copy'n'pasted that code from someone else, then start by reading it, learning how it works, and then thinking about modifications: or better, throw it away, and write your own - you won't learn much or indeed anything for copying, and that means you will both have an even harder job with the next homework task, and probably fail the course when it comes to your exams.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900