Write a program that accepts values into them and display those values.
Sample Questions and answers
1.
struct date
{
int dd;
int mm;
int yy;
};
2.
struct date {
int dd;
int mm;
int yy;
main()
{
struct date new_date;
printf ("\nEnter the date ");
scanf ("%d", &new_date.dd) ;
fflush(stdin);
printf ("\nEnter the month ");
scanf( "%d", &new_date.mm);
fflush (stdin) ;
printf("\nEnter the year ");
scanf ("%d", &new_date .yy) ;
fflush (stdin);
printf("\nThe date is :%d-%d-%d , new_date.dd, new_date .mm, new_date.yy);
}
3.
#include < stdio.h >
struct add {
int door_no;
char street [10] ;
char place (10] :
int PIN;
};
struct student
{
char name (10]:
int rollno;
struct add address;
};
void main ()
{
struct student student1;
printf("\nEnter the name of the student ");
scanf ( "%s", student1.name) ;
fflush (stdin);
printf ("\nEnter the roll no. of the student ") ;
scanf "%d", &student1.rollno);
fflush (stdin);
printf ("\nEnter the door no. ");
scanf ("%d", &student1.address. door_no) ;
fflush(stdin) ;
printf ( "\nEnter the street name ");
scanf ("%s", student1.address. street) ;
fflush (stdin);
printf ("\nEnter the area name ") ;
scanf("%6, student1.address.place);
fflush (stdin) ;
printf("\nEnter the pincode ");
scanf("%d", &student 1.address. PIN) ;
fflush (stdin) ;
printf ("\n The student's details are ");
printf ("\nThe name is : %s", student1.name);
printf ("\nThe rollno is :%d", student1.rollno);
printf ("\nThe address is : %d %s, ", student1.address.door_no, student1.address.street);
printf ("\n %s,", student1.address.place) ;
printf ("\n PIN - %d", student1.address.PIN);
}