VB icon

Ordinal Number Generator in C++

Email
Submitted on: 11/24/2015 12:40:05 PM
By: Jake R. Pomperada  
Level: Beginner
User Rating: Unrated
Compatibility: C++ (general), Microsoft Visual C++, Borland C++, UNIX C++
Views: 3243
author picture
 
     A program that I wrote using C++ as my programming language that will ask the user to enter or give a number and then our program will generate the corresponding ordinal numbers. In this program I am using CodeBlocks 8.02 as my editor and Dev C++ as my compiler that is already integrated with CodeBlocks 8.02. 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 enter or give a number and then our program will generate the corresponding ordinal numbers. In this program I am using CodeBlocks 8.02 as my editor and Dev C++ as my compiler that is already integrated with CodeBlocks 8.02.
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.cpp
// Written By: Mr. Jake R. Pomperada, MAED-IT
// Tools : CodeBlocks 8.02
// Date : November 24, 2015
#include <iostream>
using namespace std;
int test(int i) {
char *message;
int a=0, mod100 = 0, mod10 = 0;
cout << "\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";
 }
 cout <<" " << a << message << " ";
}
}
main(){
 int number=0;
 cout << "\n";
 cout <<"\t Ordinal Number Generator in C++";
 cout << "\n\n";
 cout << "Enter a Number : ";
 cin >> number;
 test(number);
 cout <<"\n\n";
 cout << "End of the Program";
 cout << "\n\n";
}


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.