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

Recommended Answers

All 9 Replies

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

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

answer is here

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

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.

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);
}
commented: you lose, you forgot code tags despite innumerable repetition to use them. -5

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. :)

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?

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.