Sunday, November 14, 2010

A Program to enter a 4 digit integer from user and display it in characters without using loop and functions ( e.g 1654 = One Six Five Four )

/*Program to get 4 digit integer rom user and display each digit in character ( e.g 1545 should be displayed as One Five Four Five )
  Developed by : Malhar Vora
  Development Status : Completed and Tested
  Developed on : 14/11/2010
  Email : vbmade2000@gmail.com
  Web Site : www.malhar2010.blogspot.com
***********************************************************************************/  
void main()
{

 int a=0,temp=0,divisor=1000,temp1=0;

 printf("Enter no:");
 scanf("%d",&a);

 test:
  if(divisor==0)
  {
      return;
  }

  temp=a/divisor;
  divisor=divisor/10;
  temp1=temp%10;

  switch(temp1)
  {
   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");
   case 0:
    printf("Zero");
    break;
  }
  goto test;

}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.