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 mandatoryTest 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
Program
#include <stdio.h> struct student { char name[50]; int rollnumber; struct dateOfBirth { int date; int month; int year; }DOB; }; int main() { struct student std; scanf("%s%d",std.name,&std.rollnumber); scanf("%d%d%d",&std.DOB.date,&std.DOB.month,&std.DOB.year); printf("Name=%s\n",std.name); printf("RollNo=%d\n",std.rollnumber); printf("Date of birth=%d/%d/%d",std.DOB.date,std.DOB.month,std.DOB.year); return 0; }
No comments:
Post a Comment
Note: only a member of this blog may post a comment.