
- Forum
- Programming Talk
- C and C++
- A tough program help me please
A tough program help me please
This is a discussion on A tough program help me please within the C and C++ forums, part of the Programming Talk category; How to solve a program if an user inputs an number example say 1 ;the output must be in words ...
-
A tough program help me please
How to solve a program if an user inputs an number example say 1 ;the output must be in words example: ONE for all value that user gives 'n'
-
03-21-2011, 01:31 AM #2
- Join Date
- Mar 2011
- Answers
- 2
the definition of threads explains a process within a process is and it states also a running program is called thread.
-
03-21-2011, 01:33 AM #3
- Join Date
- Mar 2011
- Answers
- 2
now come to your post it is so simple if an user inputs an number example say 1 ;the output must be in words example: ONE
you can check the same using switch statement check if user enters 1 put a string for example
switch(n)
case 1
print "one"
case 2
print "two"
so on...
-
03-25-2011, 11:18 AM #4
#include<stdio.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;
clrscr();
printf("
Enter any 9 digit no: ");
scanf("%9ld",&n);
if(n<=0)
printf("Enter numbers greater than 0");
else
{
pw((n/10000000),"crore");
pw(((n/100000)%100),"lakh");
pw(((n/1000)%100),"thousand");
pw(((n/100)%10),"hundred");
pw((n%100)," ");
}
getch();
}
this is code is in C.....
for CPP
#include<iostream.h>
#include<conio.h>
void main()
{
int a[5],i,n;
clrscr();
cout<<"Enter the Value";
cin>>n;
for(i=4;i>=0;i--)
{
a[i]=n%10;
n=n/10;
}
for(i=0;i<5;i++)
{
if(a[i]!=0)
{
switch(a[i])
{
case 0:cout<<"Zero";
break;
case 1:cout<<"One";
break;
case 2:cout<<"Two";
break;
case 3:cout<<"Three";
break;
case 4:cout<<"Four";
break;
case 5:cout<<"Five";
break;
case 6:cout<<"Six";
break;
case 7:cout<<"Seven";
break;
case 8:cout<<"Eight";
break;
case 9:cout<<"Nine";
break;
}
}
}
getch();
}
if any thing u need u can ask me...
-
Sponsored Ads
«
please simplify this code. i am unable to understand it... but your team has done a great work.
|
Open images in C program
»

Reply With Quote





