how to convert 4 digit number to the following example?
Example. 4632 want to convert 4 thousand 6 hundred 3 ten 2 unit
Is there c# program to convert 4 digit no to 4 thousand 6 hundred 3 ten 2 unit manner without using any string
#include%26lt;stdio.h%26gt;
void main()
{
int num,n1,n2,n3,n4;
printf("\nEnter 4 digit number");
scanf("%d",num); //ex4632
n1 = num/1000; //n1=4
n2 = (num/100)%10 //n2=6
n3 = (num/10)%10 // n3=3
n4 = num % 10 // n4 = 2
printf("\n %d = %d thousand %d hundred %d ten $d unit",num,n1,n2,n3,n4);
}
This is the only sensible solution dude.
Reply:Without using string it is not possible. otherwise the question is incomplete try to explain it with more details.
Reply:Without using a string? Ouch. How would you store the literal string "thousand" without using a string? You'd probably have to output it one character at a time, 't', 'h', 'o', 'u'....
In fact, the "string" type was created specifically so you didn't have to do that sort of silly char-at-a-time stuff. Why are you trying to do it the hard way? A sadistic professor? :)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment