Question- Make structure with name and reg no. and make another structure with residential fees and tuition fees and display all the records;
Answer-
#include<stdio.h>
#include<conio.h>
struct student
{
char name[10];
double id;
struct fees
{
double resd;
double tut;
}s2;
}; //this structure contains the 2 structure nested in 1st one//
int main()
{
struct student s[2];
int i;
for(i=0;i<2;i++)
{
printf(“\nINPUT NAME:”);
scanf(“%s”,&s[i].name);
printf(“\n–INPUT ID:”);
scanf(“%ld”,&s[i].id);
printf(“\n–RESD. FEES:”);
scanf(“%ld”,&s[i].s2.resd);
printf(“\n–TUTION FEES:”);
scanf(“%ld”,&s[i].s2.tut);
}
for(i=0;i<2;i++)
{
printf(“\nNAME:%s”,s[i].name);
printf(“\n–ID:%ld”,s[i].id);
printf(“\n–RESD. FEES=%ld”,s[i].s2.resd); //to access the variable (first struct.second struct.memory name)
printf(“\n–TUTION FEES=%ld”,s[i].s2.tut);
}
printf(“\n\n\tPROGRAMMING @ CODE STUDIO”);
getch();
}
Output–