• THE TH PROJECT
  • BATCH
  • C
  • C#
  • Fortran
  • Javascript
  • Natural
  • SQL User Defined Function
  • Visual Basic Script
  • Visual Basic .NET
  • CONTACT
© 2025 CXCVI

C

#include <stdlib.h>

char * th(int value) {

/* Prototyped by: John Naudus */

int tempvalue;

if (value<=0)
{
    return "";
}
else
{
    tempvalue = value % 100;
    if (tempvalue==11) return"th";
    else if (tempvalue==12) return "th";
    else if (tempvalue==13) return "th";
    else
    {
        tempvalue = tempvalue % 10;
        if (tempvalue==1)
        {
        return "st";
        }
        else if (tempvalue==2)
        {
        return "nd";
        }
        else if (tempvalue==3)
        {
        return "rd";
        }
        else
        {
        return "th";
        }

    }
}
}