Monday, April 5, 2021

17.10. A file contains some hotels name, address, grade, charge and number of rooms. Write a program that performs the following task i) Display all hotels information with given grade. i) Display all hotels information whose charge is less than giver charge

#include<stdio.h> 
#include<conio.h>
struct hotel

{
char name [30],add [30];

int grade, charge, num_roon;

};
void sain()

{
Int i,j,g,n, value;

struct hotel a[100], temp;

FILE *fp:
fp=fopen ("j123.dn", "r”);

n=0;
while (fscanf(fp," %s %s %d %d %d, a[n].name,a[n].add,&a[n].grade,&a[n].charge,&a[n].num_room)! =EOF)

N++;
for (i=n-1; 1>0; i==)
for (j=0; j<1, i++)

if (a[j]).charge>a[j+1].charge)

temp=a[j];

a[j]=a[j+1};

a[j+1]=temp;

}
printf("\nEnter any grade: ");

scanf("%d", &g);
printf("\Name  Address  Grade  charge  Num_Room );

printf(“\n…….  …….....  ……..  ………  …………”);
for (i=0; i<n i++)

if(a[1].grade==g)

printf("\n%-10s %-10a %5d %6d %5d", a[1].name, a [i].add, a[i].grade, a[1].charge, a[1].num_room);
printf("\n\n\n Enter any value: ");

scanf ("%d", &value):
printf("\Name  Address  Grade  charge Num_Room );

printf(“\n…….   …….....     ……..  ………  …………”);
for (i=0) i<n; i++)

if (a[i].charges<=value)

printf(“\n%-10s %-10s %5d %6d %5d”,a[i].name, a[i].add,a[i].grade, a[i].charge, a[i].num_room);
getch();

}

No comments:

Post a Comment