codescracker


c++

C++ Program to Print Date



« Previous Program Next Program »


Print Date in C++

To print date in C++ programming, simply use tm structure as shown here in the following program.

C++ Programming Code to Print Current Date

Following C++ program will print the current system date on the screen (like 09/04/2010):

/* C++ Program - Print Date */
	
#include<iostream.h>
#include<conio.h>
#include<ctime.h>
void main()
{
	clrscr();
	time_t now = time(0);
	struct tm *ltm = localtime(&now);
	cout<<"Current system date is "<<ltm->tm_mday<<"/"<<1 + ltm->tm_mon<<"/"<<1900 + ltm->tm_year;
	getch();
}

When the above C++ program is compile and executed, it will produce the following result:

C++ program to print date

Same Program in Other Language

You may like the same program in other programming languages:


« Previous Program Next Program »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test