Apply Now :

Structure in C

Monday, 12 December 2011

/* C Program => Structure in C
Calibre IT & Management Institute
[ Krishna Suman ]
*/

#include <stdio.h>
#include <conio.h>
int main()
{
struct dob
{
int day;
int month;
int year;
};
struct student
{
struct dob d;
int rollno;
char name[25];
int totalmark;
}stud[25];
int n,i;
clrscr();
printf("Enter total number of students\n\n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("\nEnter details of %d-th student\n\n",i+1);
printf("\nName : ");
scanf("%s",&stud[i].name);
printf("\nRoll number : ");
scanf("%d",&stud[i].rollno);
printf("\nTotal mark : ");
scanf("%d",&stud[i].totalmark);
printf("\nDate of birth (Format:01 06 2010) : ");
scanf("%d%d%d",&stud[i].d.day,&stud[i].d.month,&stud[i].d.year);
}
clrscr();
printf("\n\n\tSTUDENTS DETAILS:\n");
for(i=0;i<n;i++)
{
printf("\n\nRoll number\t\t:\t%d",stud[i].rollno);
printf("\nName\t\t\t:\t%s",stud[i].name);
printf("\nTotel mark\t\t:\t%d",stud[i].totalmark);
printf("\nDate of birth\t\t:\t%d / %d / %d \n\n",stud[i].d.day,stud[i].d.month,stud[i].d.year);
}
getch();
return 0;
}






Share this Article on :

No comments:

Post a Comment