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.

Comments

Popular posts from this blog

Write a program to calculate a students result based on two examinations, 1 sports event, and 3 activities conducted. The weightage of activities= 30%, sports= 20% , and examinations= 50%.

Determine the intensity of shear of an oil having viscosity= 1 poise. The oil is used for lubricating the clearance between a shaft of diameter 10 cm and its journal bearing. The clearance is 1.5mm and the shaft rotates at 150 r.p.m.