Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<conio.h>
- #include<stdio.h>
- struct student
- {
- union student
- {
- char name[20];
- int roll;
- }ua;
- int marks;
- };
- void main()
- {
- struct student stud;
- char choice;
- clrscr();
- printf("\n Enter Name ? Y or N");
- fflush(stdin);
- scanf("%c",&choice);
- if(choice == 'y' || choice == 'Y')
- {
- printf("Enter Name : ");
- fflush(stdin);
- gets(stud.ua.name);
- }
- else
- {
- printf("Roll No : ");
- scanf("%d", &stud.ua.roll);
- }
- printf("\n Enter Mark : ");
- scanf("%d",&stud.marks);
- if(choice == 'y' || choice == 'Y')
- {
- printf("\n Name : %s",stud.ua.name);
- }
- else
- {
- printf("\n Roll : %d",stud.ua.roll);
- }
- printf("Mark : %d",stud.marks);
- getch();
- }
Add Comment
Please, Sign In to add comment