Simple Structure Code
Simple Structure Code
#include<stdio.h>
struct hello
{
int rn;
char name[20];
char sec[5];
};
int main()
{
struct hello n1;
printf("Enter the roll no. of student: ");
scanf("%d",&n1.rn);
printf("\n");
}
for(i=0;i<3;i++)
{
printf("ID:%d Name:%s Salary:%f \
n",data[i].emp_id,data[i].emp_name,data[i].emp_salary);
}
}
return 0;
}
WAP to read multiple employee(emp_id,
emp_name, emp_salary) & display whose
salary is greater than 10,000.
#include<stdio.h>
struct Employee
{
int emp_id;
char emp_name[20];
float emp_salary;
};
int main()
{
int i;
struct Employee data[5];
{
for(i=0;i<5;i++)
{
printf("\n");
}
for(i=0;i<5;i++)
{
if(data[i].emp_salary>10000)
printf("ID:%d Name:%s Salary:%f \
n",data[i].emp_id,data[i].emp_name,data[i].emp_salary);
}
}
return 0;
}
WAP to read multiple structure data & display
whose salary is between any two numbers.
#include<stdio.h>
struct idktable
{
int id;
char name[20];
float salary;
};
int main()
{
printf("\n");
if(n<99999)
{
for(i=0;i<n;i++)
{
printf("\n");
}
for(i=0;i<n;i++)
{
printf("ID:%d Name:%s Salary:%f \n",idk[i].id,idk[i].name,idk[i].salary);
}
}
else
{
x=99999-n;
return 0;
}
Size allocation in Union structure & simple
structure with same variables.
#include<stdio.h>
#include<string.h>
struct table
{
int id;
char name;
float no;
};
union table2
{
int id;
int name;
float no;
};
int main()
{
struct table a;
union table2 b;
printf("The total size of the structure: %d \n",sizeof(a));
printf("The total size of the union structure: %d",sizeof(b));
}