0% found this document useful (0 votes)
3 views

Structure more programs

The document contains C programs for managing student and employee records. The first program inputs student details and displays records of those living in Kathmandu, while the second counts employees with salaries between 25,000 and 30,000. The third program displays records of employees within the specified salary range.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Structure more programs

The document contains C programs for managing student and employee records. The first program inputs student details and displays records of those living in Kathmandu, while the second counts employees with salaries between 25,000 and 30,000. The third program displays records of employees within the specified salary range.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

(Structure comparing strings and listing and counting)

//write a program to input roll number, name and address of


//n no of students. Store it and display the records of those
//students
//whose address belongs to Kathmandu.

#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;
}

Compiled By: Er.Gaurab Mishra ( HOD, Computer Department) K.M.C BagBazar +2


//write a program to input id, name and salary of
//n no of employees. Store it and count the number of
//records of
//those employees having salary between 25000 and 30000.

#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;
}

//write a program to input id, name and salary of


//n no of employees. Store it and display the records of those
//students
//whose employees having salary between 25000 and 30000.

#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;
}

Compiled By: Er.Gaurab Mishra ( HOD, Computer Department) K.M.C BagBazar +2

You might also like