#include<stdio.h>
struct date{
int day;
int month;
int year;
};
struct student {
char name [50];
int roll;
char address[50];
struct date dob;
};
main()
{
int i,j,n;
struct student a[50];
{
printf("How many data you want to input?");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("Enter your name ");
scanf("%s",&a[i].name);
printf("Enter your roll");
scanf("%d",&a[i].roll);
printf("Enter your address ");
scanf("%s",&a[i].address);
printf("Enter your Date of Birth (dd/mm/yy)");
scanf("%d%d%d",&a[i].dob.day,&a[i].dob.month,&a[i].dob.year);
}
printf("\n");
for(j=0;j<n;j++)
{
printf("Name :- %s \n ",a[j].name);
printf("Roll Number :- %d\n",a[j].roll);
printf("Address :- %s \n ",a[j].address);
printf("Date of Birth(dd/mm/yy) :- %d/%d/%d\n",a[j].dob.day,a[j].dob.month,a[j].dob.year );
printf("\n");
}
}
}
3 Comments
very good
ReplyDeleteU can't use "&" while reading a string
DeleteThank-you this helps me to give exact answer of my assignment
ReplyDelete