Академический Документы
Профессиональный Документы
Культура Документы
SPECIFICATION:
UNION
(15)(b) C Program to Show Working ability of Structure and Union
ALGORITHM:
Step 1: Start
Step 2: Define structrure job s globally
2.1: Declare variable name,salary,worker_no
Step 3: Denife union job u globally
3.1: Declare variable name,salary,worker_no
Step4: Display sizof
4.1: job s
4.2: job u
Step5: Stop
FLOWCHART
START
Display
sizeof(s),sizeof(u)
stop
STRUCTURE:
UNION:
++++++++++++++++++++++++
++++++++++++++++++++++
Job:- (s)
Job:- (u)
Name
Name
Salary
Salary
Worker_no.
PROGRAM
/*C program to display the working ability of structure and union */
Program name:
// wk15b.c
/* Done By : C-Faculty
Dated: 15/10/2013*/
#include<stdio.h>
struct job
{
char name[32];
float salary;
int worker_no;
}s;
union job1
{
char name[32];
float salary;
int worker_no;
}u;
int main()
{
printf(size of structure is %d,sizeof(s));
printf(size of union is %d,sizeof(u));
return(0);
}
PROCEDURE FOR EXECUTING THE PROGRAM:
Step 1: After typing the program, press ESC button+shift+: and then type wq(to save the
program and quit)
Step 2: Now compile the program by using the following command
cc wk15b.c lcurses -lm
Department of Computer Science & Engg