C++ Programming

Program to Set a Structure to Hold a Date (Month, Day, Year)

Write a Program to set a structure to hold a date(month, day, year). Assign values to members of structure and print out the values in the format :dd/mm/yy by function. Pass the structure to the function.

Algorithm:

  1. Start
  2. Define an structure date with members month ,day and year.
  3. Create a function date_format(date).
  4. Enter date in main function.
  5. Display date

Source Code

#include<iostream.h>
#include<conio.h>

typedef struct
               {
               int day;
               int month;
               int year;
               }date;
void date_format(date);
void main()
{
 date d={3,7,2014};
 clrscr();
 date_format(d);
 getch();
}

void date_format(date d)
{
cout<<"Current Date :"<<d.day<<"//"<<d.month<<"//"<<d.year;
}
Back to top button