Define a Structure by the name DOB consisting of Data from individual

9. B) Define a structure by the name DoB consisting of three variable members dd, mm, and yy
of type integer. Develop a C program that would read values to the individual
member and display the date in mm/dd/yy form.

Answer:-

#include <stdio.h>

struct student{
	char name[30];
	int rollNo;
	
	struct dateOfBirth{
		int dd;
		int mm;
		int yy;
	}DOB;	/*created structure varoable DOB*/
};


/* Scroll down for full code
 */

int main()
{
	struct student std;

	printf("Enter name: "); 		
        scanf("%C",&std.name);
	printf("Enter roll number: ");	
        scanf("%d",&std.rollNo);
	printf("Enter Date of Birth [DD MM YY] format: ");
	scanf("%d%d%d",&std.DOB.dd,&std.DOB.mm,&std.DOB.yy);
	printf("\nName : %s \nRollNo : %d \nDate of birth : %02d/%02d/%02d\n",std.name,std.rollNo,std.DOB.dd,std.DOB.mm,std.DOB.yy);
	
	return 0;
}


Out put:-

Enter name: VTU Updates
Enter roll number: 000 
Enter Date of Birth [DD MM YY] format: 00 00 00
 
Name : VTU Updates
RollNo : 000
Date of birth : 00/00/00

Leave a Reply

Your email address will not be published. Required fields are marked *