Problem
Write a program that compares two given dates. To store date use structure say date that contains three members namely date, month and year. If the dates are equal then display message as "Equal" otherwise "Unequal".Solution - Code
#include<stdio.h>#include<conio.h>
#include<stdlib.h>
#include<string.h>
struct dt_cmp
{
int day;
int month;
int year;
};
main()
{
struct dt_cmp s[2];
int i;
for (i=0;i<2;i++)
{
printf ("Enter day : ");
scanf ("%d",&s[i].day);
printf ("Enter month : ");
scanf ("%d",&s[i].month);
printf ("Enter year : ");
scanf ("%d",&s[i].year);
}
if ( (s[0].day == s[1].day) && (s[0].month == s[1].month) && (s[0].year == s[1].year) )
printf ("Equal\n");
else
printf ("Unequal\n");
system("pause");
}
No comments :
Post a Comment
Note: Only a member of this blog may post a comment.