C program to print the student address using the union concept.

 

C program
C PROGRAM

C program to print the student address the using union concept

#include <stdio.h>
#include<conio.h>
 union student
  {
  char name[30];
  int rollnumber;
  char branch[10];
  };
  void main()
  {
  union student stud;
  clrscr();
  printf("\n enter name:\n");
  scanf("%s",stud.name);
  printf ("\n student name is:%s",stud.name);
  printf ("\n enter rollnumber:\n");
  scanf("%d",&stud.rollnumber);
  printf ("\n student rollnumber is:%d",stud.rollnumber);
  printf ("\n enter branch:\n");
  scanf("%s",stud.branch);
  printf ("\n student branch is:%s",stud.branch);
  getch();
  }

OUTPUT :

enter name:

arunraj

 student name is:arunraj

 enter rollnumber:

20

 student rollnumber is:20

 enter branch:

mechanical

 student branch is:mechanical

Process finished.

No comments:

Post a Comment




Copyright Ⓒ 2022 | Mechpedia | All Right Reserved.