2/27/2009

C Program To Perform Array Of Structure



/*C Program To Perform 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;
    void call(struct date);
    void call1(int);
    void call2(struct date[] ,int);

    printf("How many date you want to print\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);

      call(d[0]);
      call1(d[0].year);
      call2(d,n);

    return 0;
}
void call2(struct date d[], int n)
{
    int i;
      printf("Displaying the dates\n");
        for(i=0;i<n;i++)
        {
            printf("%d/%d/%d\n",d[i].day,d[i].month,d[i].year);

        }
}
void call1(int year)
{
    printf("Year= %d\n",year);
}
void call(struct date x)
{
    printf("%d/%d/%d\n",x.day,x.month,x.year);
} 
Out Put:
How many date you want to print
1
Enter the dates:
23
1
2009
23/1/2009
Year= 2009
Displaying the dates
23/1/2009

No comments:

Post a Comment