write a c program to print the values in words
eg:- 143 written it has (one hundred and forty three)&
104, 114 are also written words

Answers were Sorted based on User's Feedback



write a c program to print the values in words eg:- 143 written it has (one hundred and forty three..

Answer / prashant

Sir, i am not able to answer of this program. please send
to me answer of this program.

Is This Answer Correct ?    10 Yes 7 No

write a c program to print the values in words eg:- 143 written it has (one hundred and forty three..

Answer / vadivel t

In the code above, which i have answered has unwanted
assignment to No ie ., no = 999, and i, j and all pls
neglect those parameters.. just i hav written in hurry...
Dont mind

Is This Answer Correct ?    1 Yes 2 No

write a c program to print the values in words eg:- 143 written it has (one hundred and forty three..

Answer / shameer.k.g

i have seen above this big codeing is not needed because it
is simple program,it need only very less codeing, i have no
time to write ,i have studied this program in
btech,tommorow i have written test for dell

Is This Answer Correct ?    1 Yes 2 No

write a c program to print the values in words eg:- 143 written it has (one hundred and forty three..

Answer / vikas

Can any one help me with this please, I cant get it right. I
have a test on 23/05/2011... Thanks

1
1 2
1 2 3
1 2 3 4

Is This Answer Correct ?    0 Yes 2 No

write a c program to print the values in words eg:- 143 written it has (one hundred and forty three..

Answer / vadivel t

Hi,

I have written code for only 3 digit numbers(u may not get
exact result for 100, 200, 113 etc ). This is just for an
idea from which u can build ur logic.
I accept... This code can be optimised.

Dont think that code is too lengthy... cos we hav to hav
limited if, else if or switch for this requirement.

Apply ur logic for 123455677 kind of nos.

#include <stdio.h>
/*Convert no to word... only for 3 digit nos*/
void ConvertToWord(int length);
char* Tens(int *a);
int Temp[10], Length = 0;

int main()
{
int No = 999, DupNo, i, j;
printf("ENTER THE THREE DIGIT NO: ");
scanf("%d", &No);
DupNo = No;
while(DupNo != 0)
{
Temp[Length] = DupNo % 10;
DupNo = DupNo / 10;
Length++;
}
printf("%d - ", No);
ConvertToWord(Length);
_getch();
}


void ConvertToWord(int Length)
{
while(Length != 0)
{
switch(Length)
{
case 0:
break;
case 1:
switch(Temp[Length - 1])
{
case 0:
break;
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;
}
Length--;
break;

case 2:
switch(Temp[Length -1])
{
case 0:
break;
case 1:
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;
}
Length--;
break;

case 3:
printf("%s HUNDRED AND ", Tens(&Temp[--
Length]));
break;
}
}

}

char* Tens(int *a)
{
char *ch;
switch(*a)
{
case 0:
ch = "ZERO";
break;
case 1:
ch = "ONE";
break;
case 2:
ch = "TWO";
break;
case 3:
ch = "THREE";
break;
case 4:
ch = "FOUR";
break;
case 5:
ch = "FIVE";
break;
case 6:
ch = "SIX";
break;
case 7:
ch = "SEVEN";
break;
case 8:
ch = "EIGHT";
break;
case 9:
ch = "NINE";
break;
}
return ch;
}

Is This Answer Correct ?    3 Yes 7 No

Post New Answer

More C Interview Questions

write a C and C++ programme to implement the A,bubble sort B,quick sort C,insertion sort D,sequential search E,binary search

1 Answers   ADP, TCS,


Write a function in c to find the area of a triangle whose length of three sides is given.

2 Answers  


how we can make 3d venturing graphics on outer interface

1 Answers   Microsoft,


How do you determine whether to use a stream function or a low-level function?

0 Answers  


What is break in c?

0 Answers  






main() { int arr[5]={23,67}; printf("%d%d%d",arr[2],arr[3],arr[4]); }

9 Answers   TCS,


Explain how can you check to see whether a symbol is defined?

0 Answers  


Write a c program to build a heap method using Pointer to function and pointer to structure ?

0 Answers   MAHINDRA, Protech, Sivan Tech,


what is associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;

0 Answers   L&T,


Is there a way to jump out of a function or functions?

0 Answers  


Explain the difference between #include "..." And #include <...> In c?

0 Answers  


what will be the output of this program? #include<stdio.h> #define cube(x) x*x*x void main() { int i,j=5; i=cube(j+3); printf("i=%d",i); }

6 Answers   IBM,


Categories