VB icon

Ordinal Number Generator in C

Email
Submitted on: 11/24/2015 12:24:14 PM
By: Jake R. Pomperada  
Level: Beginner
User Rating: Unrated
Compatibility: C, Borland C++
Views: 2413
author picture
 
     A program that I wrote using C as my programming language that will ask the user to give a number and then our program will generate the ordinal numerical values in a given number by our user. In this sample program I am using Turbo C 2.0 For DOS that is widely available free to download over the Internet. If you have some questions please send me an email at jake.r.pomperada@gmail.com and jakerpomperada@yahoo.com. My mobile number here in the Philippines is 09173084360.

 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: Ordinal Number Generator in C
// Description:A program that I wrote using C as my programming language that will ask the user to give a number and then our program will generate the ordinal numerical values in a given number by our user. In this sample program I am using Turbo C 2.0 For DOS that is widely available free to download over the Internet.
If you have some questions please send me an email at jake.r.pomperada@gmail.com and jakerpomperada@yahoo.com. 
My mobile number here in the Philippines is 09173084360.
// By: Jake R. Pomperada
//**************************************

/* ordinal.c */
/* Written By: Mr. Jake R. Pomperada, MAED-IT */
/* Tools : Turbo C 2.0 For DOS*/
/* Date : November 24, 2015 */
#include <stdio.h>
#include <conio.h>
int test(int i) {
char *message;
int a=0, mod100 = 0, mod10 = 0;
printf("\n");
for (a=1; a<=i; a++) {
 mod100 = a % 100;
 mod10 = a % 10;
if (mod10 == 1 && mod100 != 11) {
message= "st";
} else if (mod10 == 2 && mod100 != 12) {
 message="nd";
}
else if (mod10 == 3 && mod100 != 13) {
message= "rd";
} else {
 message= "th";
 }
 cprintf(" %d%s " ,a,message);
 delay(2000);
}
}
main(){
 int number=0;
 clrscr();
 textcolor(WHITE);
 printf("\n");
 cprintf("Ordinal Number Generator in C");
 printf("\n\n");
 cprintf("Enter a number : ");
 scanf("%d",&number);
 test(number);
 printf("\n\n");
 cprintf(" End of Program");
 getche();
}



Other 69 submission(s) by this author

 


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.