2/27/2009

C Program Array Of Structure



/*C Program Array Of Structure */

#include <stdio.h>
#include <stdlib.h>


struct date
{
    int day;
    int month;
    int year;
};
int main()
{
    struct date d[10];
    int i,n;
    printf("How many date you want to input\n");
      scanf("%d",&n);
    printf("Enter the dates:\n");
      for(i=0;i<n;i++)
      scanf("%d%d%d",&d[i].day,&d[i].month,&d[i].year);

      printf("Printing the dates\n");
        for(i=0;i<n;i++)
        {
            printf("%d/%d/%d\n",d[i].day,d[i].month,d[i].year);

        }
    return 0;
}
Out Put:
How many date you want to input
3
Enter the dates:
1 3 2009
3 1 2008
4 2 2007
Printing the dates
1/3/2009
3/1/2008
4/2/2007

No comments:

Post a Comment