954,479 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Billion numbers to word c language program

Sir, i do have this problem and im quite unaware about the variable declaration and the algorithm in creating this problem? thank you.

Rein Valdez
Newbie Poster
21 posts since Jan 2009
Reputation Points: 5
Solved Threads: 0
 

you mean 1,000,000,000,000 or 1,000,000,000

jbennet
Moderator
Moderator
18,523 posts since Apr 2005
Reputation Points: 1,826
Solved Threads: 601
 

actually it will be up to 99,999,999,999. Please help me. thanks.

Rein Valdez
Newbie Poster
21 posts since Jan 2009
Reputation Points: 5
Solved Threads: 0
 

answer is here

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

Thanks sir. Sir's can I post the code snippet that I have now so far? thanks. :)

Rein Valdez
Newbie Poster
21 posts since Jan 2009
Reputation Points: 5
Solved Threads: 0
 
Thanks sir. Sir's can I post the code snippet that I have now so far? thanks. :)

Post away :) and don't forget to use code tags so that I don't have to do it for you.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

ok sir, thank you.

#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include<conio.h>
#include<string.h>


void pw(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;
char *num;
char* c;

clrscr();

printf("Enter any 9 digit no: ");
gets(num);
while( (c=strchr(num,',')) > 0)
{
	memmove(c,c+1,strlen(c-1));
	}

n=atol(num);

if(n<=0)
printf("Enter numbers greater than 0");

else
{
pw((n/1000000000),"Billion");
pw(((n/100000000)%100),"Hundred Million");
pw(((n/1000000)%100),"Million");
pw(((n/100000)%10),"Hundred thousand");
pw(((n/1000)%100),"Thousand");
pw(((n/100)%10),"Hundred");
pw((n%100)," ");
}
getch();
//return 0;
}


void pw(long n,char ch[])
{
(n>19)?printf("%s %s ",ten[n/10],one[n%10]):printf("%s ",one[n]);
if(n)printf("%s ",ch);
}
Rein Valdez
Newbie Poster
21 posts since Jan 2009
Reputation Points: 5
Solved Threads: 0
 

Thank you very much sir for answering my one problem. thanks. I just give you credit for the snippet.

My problem is with the displaying of numbers in word format because I'm in two minds about the capacity of long data type. :)

Rein Valdez
Newbie Poster
21 posts since Jan 2009
Reputation Points: 5
Solved Threads: 0
 

You were asked to use code tags which are described
1) in the Rules you were asked to read when you registered
2) in the text at the top of this forum
3) in the announcement at the top of this forum titled Please use BB Code and Inlinecode tags
4) in the sticky post above titled Read Me: Read This Before Posting
5) any place CODE tags were used, even in responses to your posts
6) on the background of the box you actually typed your message in

Did you bother to read any of the suggested posts and rules?

WaltP
Posting Sage w/ dash of thyme
Moderator
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
 

I am very sorry for not reading the rules of this forum. So sorry.

Rein Valdez
Newbie Poster
21 posts since Jan 2009
Reputation Points: 5
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You