#include <stdio.h>
#include <string.h>
union id
{
char name[20];
int roll_no;
};
struct student
{
union id cand;
int marks;
};
int main() {
struct student stud;
int choice;
printf("\n you can enter name (or) roll_number of student\n");
printf("\n do you want to enter the name?(enter1 if yes) or (enter 0 if no):");
scanf("%d",&choice);
if(choice==1)
{
printf("\n enter the name:");
scanf("%s",stud.cand.name);
}
else
{
printf("\n enter roll_no");
scanf("%d",&stud.cand.roll_no);
}
printf("\n enter the marks:");
scanf("%d",&stud.marks);
if(choice==1)
printf("\n name:%s",stud.cand.name);
else
printf("\n roll_number:%d",stud.cand.roll_no);
printf("\n marks:%d",stud.marks);
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: