Professional Documents
Culture Documents
CODE:
#include <stdio.h>
void main ()
{ int height[9]; int i, j, a, x; int n = 9;
printf("Enter the students height \n");
for (i = 0; i < n; ++i)
scanf("%d", &height[i]); for (i = 0;
i< n; ++i)
{ for (j = i + 1; j < n; ++j)
{ if (height[i] <
height[j])
{
a = height[i];
height[i] = height[j];
height[j] = a;
}
} } printf(" Printing in descending order
\n"); for (i = 0; i <9; ++i)
{ printf("%d\t",
height[i]);
} printf(" \n\nPrinting in 3 X 3
\n"); x = 0; for (i = 0; i < 3; ++i)
{ for (j = 0; j < 3;
++j) {
printf("%d\t",
height[x]); x=x+1;
}
printf("\n");
}
}
OUTPUT:
Enter the students height :
45
55
65
75
95
130
150
160
170
Printing in descending order
170 160 150 130 95 75 65 55 45
Printing in 3 X 3
170 160 150
130 95 75
65 55 45
CODE:
#include<stdio.h>
struct org
{
char emp_name[30];
int emp_id, salary;
char emp_doj[8];
}; void
main() {
struct org employee[20];
int n,i;
void disp()
{
printf("\nEmployees Information\n");
for(i=0;i<n;i++)
{
if(employee[i].salary >= 5000)
{
printf("\nPerson %d\n Name :
%s",i+1,employee[i].emp_name);
printf("\nEmployee Id : %d",employee[i].emp_id);
printf("\nEmployee DOJ : %s",employee[i].emp_doj);
printf("\nEmployee Salary : %d",employee[i].salary);
}
}
}
printf("\nEnter the number of Employees in your organization
:");
scanf("%d", &n);
for(i = 0; i < n; i++)
{ printf("\nEnter Person %d\n Name
:",i+1);
scanf("%s",&employee[i].emp_name);
printf("\nEmployee Id :");
scanf("%d",&employee[i].emp_id); printf("\nEmployee
Date of Joining :");
scanf("%s",&employee[i].emp_doj);
printf("\nEmployee Salary :");
scanf("%d",&employee[i].salary);
} disp();
}
OUTPUT:
Enter Person 1
Name: Sharan
Enter Person 2
Name : mukesh
Employee Id : 30988
Enter Person 3
Name : keerthi
Employee Id :40097
Employees Information
Person 1
Name : Sharan
Employee Id : 30987
Employee DOJ : 19/7/2013
Employee Salary : 10000
Person 2
Name : mukesh
Employee Id : 30988
Employee DOJ : 19/6/2017
Employee Salary : 3000