ACP_U1p5.c

#include<stdio.h> #include<conio.h> struct hotel { char name[30]; char add[40]; char grade[5]; int charge; int roomno; }; void custom(struct hotel h[5],int); void main() { struct hotel h[5]; int i,charge; clrscr(); for(i=0;i<5;i++) { printf("hotel[%d]:",i+1); printf("enter hotel grade:"); scanf("%s",&h[i].grade); printf("enter hotel name:"); scanf("%s",&h[i].name); printf("enter hotel address:"); scanf("%s",&h[i].add); printf("enter room no:"); scanf("%d",&h[i].roomno); printf("enter room charge"); scanf("%d",&h[i].charge); } printf("enter charge"); scanf("%d",&charge); custom(h,charge); getch(); } void custom(struct hotel h[5], int charge) { int i; printf("==============hotels==========="); printf("\name\taddress\tgrade\tcharges\troom\n"); for(i=0;i<5;i++) { if(h[i].charge<charge) { printf("%s\t%s\t%s\t%d\t%d\n",h[i].name,h[i].add,h[i].grade,h[i].charge,h[i].roomno); } } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.