Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

[CODE] Program that convert numbers to words(Turbo C)

research lng yan sa net . hehe . puro "if else" lng yan or "do while" . .
ginawa na din namin yan sa java . .

may kasama pang conversion sa roman numerals . mas madali un . haha . :PPPPP
 
Re: [HELP] Program that convert numbers to words(Turbo C)

Here's the code!:hyper:

Code:
#include<stdio.h>
#include<conio.h>
		/*Write a program that accepts a number and output
		its equivalent in words(maximum input number is 3000).
		For example:
			Enter a number: 1380
			one thousand three hundred eighty */
main()
{
	int n,r,th,h,t,o;
	clrscr();
	printf("Enter a number: ");
	scanf("%d", &n);
	th=n/1000;
	n=n%1000;
	h=n/100;
	n=n%100;
		/*If the input number is 11 - 19
			this code will be executed*/
	if ((n>1) && (n<20))
	{
		t=0;
		o=0;
		r=n%10;
	}
	else
	{
		t=n/10;
		n=n%10;
		o=n;
	}
	switch(th)
	{
		case 1: printf("One thousand "); break;
		case 2: printf("Two thousand "); break;
		case 3: printf("Three thousand "); break;
	}
	switch(h)
	{
		case 1: printf("one hundred "); break;
		case 2: printf("two hundred "); break;
		case 3: printf("three hundred "); break;
		case 4: printf("four hundred "); break;
		case 5: printf("five hundred "); break;
		case 6: printf("six hundred "); break;
		case 7: printf("seven hundred "); break;
		case 8: printf("eight hundred "); break;
		case 9: printf("nine hundred "); break;
	}
	switch(r)
	{
		case 1:printf("eleven ");break;
		case 2:printf("twelve ");break;
		case 3:printf("thirteen ");break;
		case 4:printf("fourteen ");break;
		case 5:printf("fifteen ");break;
		case 6:printf("sixteen ");break;
		case 7:printf("seventeen ");break;
		case 8:printf("eighteen ");break;
		case 9:printf("nineteen ");break;
	}
	switch(t)
	{
		case 1:printf("ten ");break;
		case 2:printf("twenty ");break;
		case 3:printf("thirty ");break;
		case 4:printf("forty ");break;
		case 5:printf("fifty ");break;
		case 6:printf("sixty ");break;
		case 7:printf("seventy ");break;
		case 8:printf("eighty ");break;
		case 9:printf("ninety ");break;
	}
	switch(o)
	{
		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();
}



ganun lang pala un.. tapos na ang analization ko.. maicode nga sa java.. :) thanks
 
dali lang nyan. Ginawa ko yan dati sa VB.Net. hehe. hanggang trillion pa nga yung ginawa ko.
 
sa java nmen to ginawa sa c roman numeral nmn ginawa nmen
 
Mga sir, panu po ba mag work yung "%" modulus operator sa C programming?


Bkit po ba kelangan ito? like sa source code...

t = n / 1000;
n = n % 1000;

bkit kailangan pa po ba ng "%" ??? Please pa help po ng maunawaan ko kung anung silbe nya.
 
eto po complete code with limit and zero :)

#include<stdio.h>
/*Write a program that accepts a number and output
its equivalent in words(maximum input number is 3000).
For example:
Enter a number: 1380
one thousand three hundred eighty */
main()
{
int n,r,th,h,t,o;
clrscr();
printf("Enter a number: ");
scanf("%d", &n);

if (n>3000){
printf("Out of reach, limit is 3000"); /*limit*/
}else if (n==0){
printf("zero"); /*if the inputted value is zero*/
}else{

th=n/1000;
n=n%1000;
h=n/100;
n=n%100;
t=n/10;
/*If the input number is 11 - 19
this code will be executed*/
if ((n>10) && (n<20))
{
t=0;
r=n%10;
}
else
{
n=n%10;
o=n;
}
}
switch(th)
{
case 1: printf("One thousand "); break;
case 2: printf("Two thousand "); break;
case 3: printf("Three thousand "); break;
}
switch(h)
{
case 1: printf("one hundred "); break;
case 2: printf("two hundred "); break;
case 3: printf("three hundred "); break;
case 4: printf("four hundred "); break;
case 5: printf("five hundred "); break;
case 6: printf("six hundred "); break;
case 7: printf("seven hundred "); break;
case 8: printf("eight hundred "); break;
case 9: printf("nine hundred "); break;
}

switch(t)
{
case 1: printf("ten ");break;
case 2: printf("twenty ");break;
case 3: printf("thirty ");break;
case 4: printf("forty ");break;
case 5: printf("fifty ");break;
case 6: printf("sixty ");break;
case 7: printf("seventy ");break;
case 8: printf("eighty ");break;
case 9: printf("ninety ");break;
}
switch(r)
{
case 1: printf("eleven ");break;
case 2: printf("twelve ");break;
case 3: printf("thirteen ");break;
case 4: printf("fourteen ");break;
case 5: printf("fifteen ");break;
case 6: printf("sixteen ");break;
case 7: printf("seventeen ");break;
case 8: printf("eighteen ");break;
case 9: printf("nineteen ");break;
}
switch(o)
{
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();
}
 
Last edited:
Code:
#include <stdlib.h>
#include<stdio.h>



void expand(int);
int main()
{
    int num;
    printf("Enter a number : ");
    scanf("%d", &num);
    printf("\n");
    expand(num);
    printf("\n\n");
    system("PAUSE");
}


void expand(int value)
{
    const char * const ones[20] = {"zero", "one", "two", "three","four","five","six","seven",
    "eight","nine","ten", "eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen",
    "eighteen","nineteen"};
    const char * const tens[10] = {"", "ten", "twenty", "thirty","forty","fifty","sixty","seventy",
    "eighty","ninety"};

    if(value<0)
    {
        printf("minus ");
        expand(-value);
    }
    else if(value>=1000)
    {
        expand(value/1000);
        printf(" thousand");
        if(value % 1000)
        {
            if(value % 1000 < 100)
            {
                printf( " and");
            }
            printf( " " );
            expand(value % 1000);
        }
    }
    else if(value >= 100)
    {
        expand(value / 100);
        printf(" hundred");
        if(value % 100)
        {
            printf( " and ");
            expand (value % 100);
        }
    }
    else if(value >= 20)
    {
        printf(tens[value / 10]);
        if(value % 10)
        {
           printf( " ");
            expand(value % 10);
        }
    }
    else
    {
        printf(ones[value]);
    }
    return;
}

Share ko lang :)

Dev C++
 
Mga sir, panu po ba mag work yung "%" modulus operator sa C programming?


Bkit po ba kelangan ito? like sa source code...

t = n / 1000;
n = n % 1000;

bkit kailangan pa po ba ng "%" ??? Please pa help po ng maunawaan ko kung anung silbe nya.

Remainder ang return value ng mod. n/1000 gets the thousands place and n%1000 returns the remainder (0 to 999).
 
Re: [HELP] Program that convert numbers to words(Turbo C)

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

main()

{
int num,thou,hund,tens,ones;
clrscr();
printf("\n Enter a number: ");
scanf("%d",&num);

thou=num/1000;
if(num<=3000)
{
num=num%1000;
switch(thou)
{
case 1: printf(" one thousand"); break;
case 2: printf(" two thousand"); break;
case 3: printf(" three thousand"); break;
}

hund=num/100;
num=num%100;
switch(hund)
{
case 1: printf(" one hundred"); break;
case 2: printf(" two hundred"); break;
case 3: printf(" three hundred"); break;
case 4: printf(" four hundred"); break;
case 5: printf(" five hundred"); break;
case 6: printf(" six hundred"); break;
case 7: printf(" seven hundred2"); break;
case 8: printf(" eight hundred"); break;
case 9: printf(" nine hundred"); break;
}

{

switch(tens)
{
case 1: printf(" eleven"); break;
case 2: printf(" twelve"); break;
case 3: printf(" thirteen"); break;
case 4: printf(" fourteen"); break;
case 5: printf(" fifteen"); break;
case 6: printf(" sixteen"); break;
case 7: printf(" seventeen"); break;
case 8: printf(" eighteen"); break;
case 9: printf(" nineteen"); break;
}
}
{
tens=num/10;
switch(tens)
{
case 1: printf(" ten"); break;
case 2: printf(" tweenty"); break;
case 3: printf(" thirty"); break;
case 4: printf(" fourty"); break;
case 5: printf(" fifty"); break;
case 6: printf(" sixty"); break;
case 7: printf(" seventy"); break;
case 8: printf(" eighty"); break;
case 9: printf(" ninety"); break;
}
ones=num%10;
num=num/10;
switch(ones)
{

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;
}
}
}

else
{
printf("\n Out-of-range of 3,000");

}
getch();
return 0;
}
 


Nakita ko lang sa lab namin, sinosolve ng 4th year students.:dance:
Na-curious lang ako.
Possible po ba toh?:slap:

UPDATE: May CODE na po sa baba :D

salamat may sagot nako sa assignment
 
Back
Top Bottom