VB icon

An entertaining way of converting number into digis

Email
Submitted on: 1/6/2015 4:58:00 AM
By: The Coolest one... (from psc cd)  
Level: Beginner
User Rating: By 3 Users
Compatibility: C, C++ (general), Borland C++
Views: 1107
 
     An entertaining way of converting number into digis
 

INCLUDE files:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
//**************************************
//INCLUDE files for :An entertaining way of converting number into digis
//**************************************
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<math.h>
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: An entertaining way of converting number into digis
// Description:An entertaining way of converting number into digis
// By: The Coolest one... (from psc cd)
//
// Assumes:just follow the comments placed along with the code
//
// Side Effects:none so far
//**************************************

/********An entertaining way of converting number into digis**********/
/*********************Tried and tested by-****************************/
/************************SUMIT THAWRANI*******************************/
/**********************sumit0001@yahoo.com****************************/
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<math.h>
void main()
{
unsigned long dig,temp; //I prefer unsigned int as their range is much larger
unsigned long div; //Just make sure that the number u enter is
int num,i; // lesser than 4294977295 or be prepared to get an
int count=0,c; // awkward answer
void word(int);
clrscr();
printf("Enter the digit to be converted into words :");
scanf("%lu",&dig);
printf("\nThe number you entered is : %lu\n",dig);
printf("\nAnd this can be written in words as ..");
temp=dig;
while (temp!=0)
{ temp=temp/10;
 count++; //counts the number of digits in the given number
 }
temp=dig;
for(i=count-1;i>=0;i--)
{ c=temp/pow(10,i);
div=pow(10,i);
temp=temp%div;
sound(random(9999)); //plays different sound
delay(400); //introduces some delay
word(c); //call to function word() to print word
nosound();
c=0;
}
getch();
}
void word(int i)
{
switch(i){
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;
case 0: printf(" Zero ");
	break;
				}
return;
}


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.