APJ ABDUL KALAM TECHNOLOGICAL UNIVERSITY Previous Years Question Paper & Answer

Course : B.Tech

Semester : S1 and S2

Year : 2018

Term : MARCH

Branch : BIOTECHNOLOGY

Scheme : 2015 Full Time

Course Code : CS 100

Page:8





PDF Text (Beta):

Syntax: union
tag_name

{ data type

\/2॥ 11211161; data
type var_name2;
data type
var_name3; };
Example: union
student

{

int mark; char
name[10]; 1031
average;

7

#include
#include

union student

{

char name[20];
char subject[20];
float percentage;

)

int main() {
union student 7600/61;
union student record2;

// assigning values to record1 union variable
strcpy(recordi.name, "Raju");
strcpy(record1.subject, "Maths");

record1.percentage = 86.50;

printf("Union record1 values example\n");
printf("Name : %s ‏,"ما‎ record1.name);
printf(" Subject : %s ‏,"ما‎ record1.subject);
printf(" Percentage : %f \n\n",
record1.percentage);

// assigning values to record2 union variable
printf("Union record2 values example\n");
strcpy(record2.name, "Mani");

printf("Name : %s ‏,"ما‎ record2.name);

strcpy(record2.subject, "Physics");
printf(" Subject : 9650", record2.subject);

record2.percentage = 99.50;
printf(" Percentage : %f \n", record2.percentage);
return 0;

}

Similar Question Papers