Skip to main content

Program to convert Birth Date or Any Date into a Name.or Find Day or Month name of Any Date.

WAP to find Any Day or Month Name of Any Date


About Program:

This program helps you to find the Day and Month of any Date / Any Year.
Here i'm using Simple Algorithm to find the Exact Day And Month name of Date.

Things which I have to Remember Before Creating a program:

  1. Check the Year is Leap or Normal Year
  2. Days of the Month some month have 30 and some have 31 
  3. Also include the Feb month condition for both 28 and 29 days
  4. last is creating a user Friendly Input
Here one thing to notice that i'm used a software for that program is Dev C++ .
Below you get Direct Downloading Link of Dev C++


Downloads Button 

#Note : when you click on Downloading link You get An ad, Don't worry just skip it from upper right Corner Button (Button show after 5 sec). It just for help us, we make more and more easy and understandable content for you regularly. Or watch Video How you download the Source code.

Watch Video tutorial

Source Code:
BirthtoName.html
/*DotClu
If you like this program please
subscribe Our Youtube Channel : https://goo.gl/NNQypi 
or search Dotclu on Youtube

Also follow us on Google+ : https://goo.gl/QxUjTL
	follow us on Twiiter: https://twitter.com/dotclu
	Like us on Facebook: https://www.facebook.com/DC1089
	our Blog: https://dotclu.blogspot.in/
	
friends Support Us We need your Support
And Enjoy program
+++++++++++++++++++++++++++++++++++
+	Convert birthdate Into Name    +
+++++++++++++++++++++++++++++++++++
*/

#include <iostream>
using namespace std;

int main(void)
{
    int DD = 32, MM = 13, YYYY = -1, NYYYY, NMM, IDAY, day, flag = 0;
   
    string month[] = {"January","February","March","April","May","June","July",
                      "August","September","October","November","December"};
	cout<<"\n\tEnter the Date Of birth\n ";
	cout<<"\n***********************************\n";
	cout<<"\n\tDay: ";
    cin >> DD;
    cout<<"\tMonth: ";
    cin >> MM;
    cout<<"\tYear: ";
    cin >> YYYY;
   cout<<"\n***********************************\n\n\n\n";
     //Error Message: User has given no input
    if(DD >= 32 || MM >= 13 || YYYY <= -1)
    {
        cout << " Please enter your birthday in this " << endl;
        cout << "     format(including spaces):      " << endl;
        cout << "            DD MM YYYY              " << endl;
        cout << "            22 01 1997              \n\n" << endl;
        return -1;
    }
   
    if(DD <= 0)
    {
        //Error Message: User has given invalid input for "Days" & "Months" fields
        if(MM <= 0)
        {            
            cout << " We don't have negative or null days and months. " << endl;
            cout << "                   Try again!                    " << endl;
            return -1;
        }
       
        //Error Message: User has given invalid input for "Days" field
        cout << " We don't have negative or null days. " << endl;
        cout << "              Try again!              " << endl;
        return -1;
    }
   
    if(MM <= 0)
    {
        //Error Message: User has given invalid input for "Months" field
        cout << " We don't have negative or null months. " << endl;
        cout << "               Try again!               " << endl;
        return -1;
    }
   
    if(DD > 31 || MM > 12 || YYYY <= 0)
    {
        if(DD > 31 && MM > 12)
        {
            //Error Message: User has given invalid input for "Days", "Months" & "Years" fields
            if(YYYY <= 0)
            {
                cout << " We have 12 months, the days of a month are up to 31 " << endl;
                cout << "       and a year should be a positive number.       " << endl;
                cout << "                     Try again!                      " << endl;
            }
            //Error Message: User has given invalid input for "Days" & "Months" fields
            else
            {
                cout << "       We have 12 months and       " << endl;
                cout << " the days of a month are up to 31. " << endl;
                cout << "            Try again!             " << endl;
            }
               
        }
        else if(DD > 31 && MM <= 12)
        {
            //Error Message: User has given invalid input for "Days" & "Years" fields
            if(YYYY <= 0)
            {
                cout << " The days of a month are up to 31 and " << endl;
                cout << " a year should be a positive number.  " << endl;
                cout << "             Try again!               " << endl;
            }
            //Error Message: User has given invalid input for "Days" field
            else
            {
                cout << " The days of a month are up to 31. " << endl;
                cout << "            Try again!             " << endl;
            }
               
        }
        else if(DD <= 31 && MM > 12)
        {
            //Error Message: User has given invalid input for "Months" & "Years" fields
            if(YYYY <= 0)
            {
                cout << "        We have 12 months and        " << endl;
                cout << " a year should be a positive number. " << endl;
                cout << "             Try again!              " << endl;
            }
            //Error Message: User has given invalid input for "Months" field
            else
            {
                cout << " We have 12 months. " << endl;
                cout << "     Try again!     " << endl;
            }
               
        }
        //Error Message: User has given invalid input for "Years" field
        else if(DD <= 31 && MM <= 12 && YYYY <= 0)
        {
            cout << " A year should be a positive number. " << endl;
            cout << "             Try again!              " << endl;
        }
        return -1;
    }
   
    switch(MM)
    {
        case 2:
           
            if((YYYY % 400) == 0 || ((YYYY % 4) == 0 && (YYYY % 100) != 0))
            {
                //Error Message: User has requested an invalid day for the month "February"
                //                and the requested "Year" is a leap year.
                if(DD > 29)
                {
                    cout << "  The year " << YYYY << " is a leap year. " << endl;
                    cout << " So, February has up to 29 days.          " << endl;
                    cout << "           Try again!                     " << endl;
                    return -1;
                }
            }
            else
            {
                //Error Message: User has requested an invalid day for the month "February"
                //              and the requested "Year" is not a leap year.
                if(DD > 28)
                {
                    cout << " The year " << YYYY << " isn't a leap year. " << endl;
                    cout << " So, February has up to 28 days.            " << endl;
                    cout << "           Try again!                       " << endl;
                    return -1;
                }
            }
            break;
           
        case 4:
            //Error Message: User has requested an invalid day for the month "April"
            if(DD > 30)
            {
                cout << " April has up to 30 days. " << endl;
                cout << "        Try again!        " << endl;
                return -1;
            }
            break;
             
        case 6:
            //Error Message: User has requested an invalid day for the month "June"
            if(DD > 30)
            {
                cout << " June has up to 30 days. " << endl;
                cout << "       Try again!        " << endl;
                return -1;
            }
            break;
       
        case 9:
            //Error Message: User has requested an invalid day for the month "September"
            if(DD > 30)
            {
                cout << " September has up to 30 days. " << endl;
                cout << "          Try again!          " << endl;
                return -1;
            }
            break;
           
        case 11:
            //Error Message: User has requested an invalid day for the month "November"
            if(DD > 30)
            {
                cout << " November has up to 30 days. " << endl;
                cout << "         Try again!          " << endl;
                return -1;
            }
            break;
    }
   
    if(MM <= 2)
    {
        NYYYY = YYYY - 1;
        NMM = 0;
    }
    else
    {
        NYYYY = YYYY;
        NMM = (4 * MM + 23) / 10;
    }
   
    //Calculating the day
    IDAY = 365 * YYYY + DD + 31 * (MM - 1) - NMM + (NYYYY / 4) - ((3 * ((NYYYY / 100) + 1) / 4));
   
    day = IDAY % 7;
   
    //This 'flag' is used for displaying the right ending after the numbers
    if(DD != 11 && DD != 12 && DD != 13)
        flag = DD % 10;
   
    switch(day)
    {
        case 0:
            cout << " You were born on Saturday, ";
            break;
           
        case 1:
            cout << " You were born on Sunday, ";
            break;
           
        case 2:
            cout << " You were born on Monday, ";
            break;
           
        case 3:
            cout << " You were born on Tuesday, ";
            break;
           
        case 4:
            cout << " You were born on Wednesday, ";
            break;
           
        case 5:
            cout << " You were born on Thursday, ";
            break;
           
        case 6:
            cout << " You were born on Friday, ";
            break;
    }
   
    if(flag == 1){
        cout << DD << "st of ";
    }
    else if(flag == 2){
        cout << DD << "nd of ";
    }
    else if(flag == 3){
        cout << DD << "rd of ";
    }
    else{
        cout << DD << "th of ";
    }
   
    cout << month[MM-1] << " of " << YYYY << "!" << endl;
   cout<<"\n\n\n++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
    cout << "\n           And if you liked it,                  " << endl;
    cout << " don't forget to subscribe us ! and folllow us    " << endl;
    cout << "            	Thank you!                         " << endl;
	cout << "              	  DotClu                           " << endl;   
   cout<<"\n++++++++++++++++++++++++++++++++++++++++++++++++++++\n";
    return 0;
} 



Comments

Popular posts from this blog

Shortest Remaining Time First (SRTF) Program in C++ || dot clu

Shortest Remaining Time First (SRTF) Program in C++ || dot clu Shortest Remaining Time First (SRTF) Shortest Remaining Time First (SRTF) Algorithm is preemptive version of Shortest Job First Algorithm. In this current process is executed until it is completed or a new process is added having lower burst time compare to the the remaining time for current process. SRTF algorithm may lead to starvation, if processes with lower burst time continues to add to cpu scheduler then the current process will never get a chance to get executed. For example consider the following table Process Arrival Time Burst Time P1 0 10 P2 1 6 P3 2 9 P4 3 4 At time t=0, Process P1 will start get executing as it is only the process present at that time. Then at t=1, Process P2 added to the CPU scheduler, at this time remaining time(Burst time) for Process P1 gets 9, as Burst time of P2 is less than the remaining time of other processes (for now there is only process P1) therefore pro...

First Fit Program and Algorithm in C++ || dot clu

First Fit Program and Algorithm in C++ || dot clu First Fit Algorithm in C and C++ Here you will learn about first fit algorithm in C and C++ with program examples. There are various memory management schemes in operating system like first fit, best fit and worst fit. In this section we will talk about first fit scheme. Suggestion: 1. First Fit 2.  Best Fit 3.  Worst Fit What is First Fit Memory Management Scheme? In this scheme we check the blocks in a sequential manner which means we pick the first process then compare it’s size with first block size if it is less than size of block it is allocated otherwise we move to second block and so on. First Fit Algorithm Get no. of Processes and no. of blocks. After that get the size of each block and process requests. Now allocate processes if(block size >= process size) //allocate the process else //move on to next block Display the processes with the blocks that are allocated to a respective...

C++ Program For PRIORITY WITH NON - PREEMPTIVE Scheduling Algorithm || dot clu

C++ Program For PRIORITY WITH  NON - PREEMPTIVE Scheduling Algorithm It is important to distinguish  preemptive  from  non - preemptive scheduling algorithms.  Preemption  means the operating system moves a process from running to ready without the process requesting it. Without  preemption , the system implements ``run to completion (or yield or block)''. Non-Preemptive Scheduling Non-Preemptive Scheduling means once a process starts its execution or the CPU is processing a specific process it cannot be halted or in other words we cannot preempt (take control) the CPU to some other process. A computer system implementing this cannot support the execution of process in a multi task fashion. It executes all the processes in a sequential manner. It is not practical as all processes are not of same priority and are not always known to the system in advance. Source Code: #include <iostream> using namespace std; int main(...