Problem Description
Create two structures as follows:
Structure 1:
Name = student
Data members = name(char), rollno(int)
Structure 2:
Name = dateOfBirth
Data members = date(int), month(int), year(int)
Create Structure Variable as "DOB"
In main function:
1. Create structure variable for student "std"
Hint: struct student std;
2. Input the values of name and roll number
Hint: std.name
3. Input the values of date, month and year
Hint: std.DOB.date
4. Display the name, roll number, Date of Birth.
Note: The structure variables, data members and structure name are CASE Sensitive.
Follow the same case mentioned in the mandatoryCODING ARENA
#include<stdio.h>
struct student
{
char name[100];
struct dateOfBirth
{
int rollno,date,month,year;
}DOB;
}std;
int main()
{
scanf("%s%d%d%d%d",std.name,&std.DOB.rollno,&std.DOB.date,&std.DOB.month,&std.DOB.year);
printf("Name=%s\nRollNo=%d\nDate of birth=%d/%d/%d",std.name,std.DOB.rollno,std.DOB.date,std.DOB.month,std.DOB.year);
return 0;
}
Test Case 1
Input (stdin)Rajesh 101 25 12 1989
Expected OutputName=Rajesh RollNo=101 Date of birth=25/12/1989
Test Case 2
Input (stdin)Bogar 102 11 11 1111
Expected OutputName=Bogar RollNo=102 Date of birth=11/11/1111
No comments:
Post a Comment