Stay Tuned!

Subscribe to our newsletter to get our newest articles instantly!

C++ Programming

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

Set a Structure

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;
}
Avatar

Tuts

About Author

Tutsmaster.org provides tutorials related to tech and programmings. We are also setting up a community for the users and students.

You may also like

program to find leap year
C++ Programming

C++ Program to Find Leap Year by Using Function

  • March 3, 2016
Write a program to find if the inputted year is a leap year or not by using the concept of