Structure more programs
Structure more programs
#include<stdio.h>
#include<string.h>
struct stud
{
int roll;
char name[50];
char address[50];
};
int main()
{
int i,j,n;
printf("/*How many student records you want toenter?*/");
scanf("%d",&n);
struct stud s[n];
for(i=0;i<n;i++)
{
printf("\nEnter Student-%d Details\n",i+1);
printf("Enter Roll no : ");
scanf("%d",&s[i].roll);
printf("Enter Name : ");
scanf("%s",&s[i].name);
printf("Address : ");
scanf("%s",&s[i].address);
Compiled By: Er.Gaurab Mishra ( HOD, Computer Department) K.M.C BagBazar +2
}
for(i=0;i<n;i++)
{
if(strcmp(s[i].address,"Kathmandu")==0)
{
printf("\n%d\t%s\t\t%s\n",s[i].roll,s[i].name,s[i].address);
}
}
return 0;
}
#include<stdio.h>
#include<string.h>
struct employee
{
int id;
char name[50];
int salary;
};
int main()
{
int i,j,n,count=0;
printf("/*How many student records you want toenter?*/");
scanf("%d",&n);
struct employee e[n];
for(i=0;i<n;i++)
{
printf("\nEnter Student-%d Details\n",i+1);
printf("Enter Id : ");
scanf("%d",&e[i].id);
printf("Enter Name : ");
scanf("%s",&e[i].name);
printf("Salary : ");
scanf("%d",&e[i].salary);
}
for(i=0;i<n;i++)
Compiled By: Er.Gaurab Mishra ( HOD, Computer Department) K.M.C BagBazar +2
{
if((e[i].salary >=25000) && (e[i].salary<=30000))
{
count++;
}
}
printf("The no of empolyees having salary between 25000
and 30000 is %d",count);
return 0;
}
#include<stdio.h>
#include<string.h>
struct employee
{
int id;
char name[50];
int salary;
};
int main()
{
int i,j,n,count;
printf("/*How many student records you want toenter?*/");
Compiled By: Er.Gaurab Mishra ( HOD, Computer Department) K.M.C BagBazar +2
scanf("%d",&n);
struct employee e[n];
for(i=0;i<n;i++)
{
printf("\nEnter Student-%d Details\n",i+1);
printf("Enter Id : ");
scanf("%d",&e[i].id);
printf("Enter Name : ");
scanf("%s",&e[i].name);
printf("Salary : ");
scanf("%d",&e[i].salary);
}
for(i=0;i<n;i++)
{
if((e[i].salary >=25000) && (e[i].salary<=30000))
{
printf("\n%d\t%s\t\t%d\n",e[i].id,e[i].name,e[i].salary);
}
}
return 0;
}