Wednesday 10 February 2016

WAP to declare two structures with the following specification

WAP to declare two structures with the following specification
                        Structure name            date                
                        Dd                               int                    day
                        Mm                              int                    month 
                        Yy                               int                    year    

                        Structure name            student
                        Rollno                         int
                        Name                           char[10]
                        Marks                          float
                        Dob                             date                 date of birth
                        Doa                             date                 date of admission in school

            Now perform the following operations:
·                                 Take an object of structure student, input the values and display the values.


#include<stdio.h>
#include<conio.h>
struct date
{int dd,mm,yy;
};
struct student
{
int rollno;
char name[10];
int marks;
struct date doj,dob;
}s;

void main()
{ clrscr();
printf("enter rollno\n");
scanf("%d",&s.rollno);
printf("enter name\n");
scanf("%s",&s.name);
printf("enter marks\n");
scanf("%d",&s.marks);
printf("enter dob  date\n");
scanf("%d",&s.dob.dd);
printf("enter dob month\n");
scanf("%d",&s.dob.mm);
printf("enter dob  year\n");
scanf("%d",&s.dob.yy);
printf("enter doj date\n");
scanf("%d",&s.doj.dd);
printf("enter doj month\n");
scanf("%d",&s.doj.mm);
printf("enter doj year\n");
scanf("%d",&s.doj.yy);
printf("\ninfo\n");
printf("rollno:-%d",s.rollno);
printf("\nname:-%s",s.name);
printf("\nmarks:-%d",s.marks);
printf("\ndate of birth:-%d-%d-%d\n",s.dob.dd,s.dob.mm,s.dob.yy);
printf("date of join:-%d-%d-%d",s.doj.dd,s.doj.mm,s.doj.yy);
getch();
}




No comments:

Post a Comment