rendered paste body#include <stdio.h>
#include <stdlib.h>
#include <string.h>
main ()
{
int rooms, room_number;
double area, cost, totalcost, lenght, breadth;
char hotel;
rooms=0;
FILE * in= fopen("rooms.txt", "r");
FILE * out= fopen("rooms1.txt", "w");
if (in == NULL)
{
printf("File cannot be found");
return 1;
}
else
{
printf("File opened successfully.\n");
}
if (out == NULL)
{
printf("File cannot be found or created");
exit(1);
}
fprintf(out, "RoomNumber RoomArea CostToCarpetRoom\n\n");
while(room_number!=0)
{
fscanf(in, "%d %lf %lf %lf", &room_number, &lenght, &breadth, &cost);
if(room_number == 0)
break;
area= lenght * breadth;
fprintf(out, "%d %10.1lf %15.2lf\n\n", room_number, area, cost);
totalcost= totalcost + cost;
rooms = ++rooms;
// largeroom =
}/*while(room_number!=0); */
fprintf(out, "%d rooms were processed\n\n", rooms);
fprintf(out, "Total cost of carpeting all the rooms is $%4.2lf\n\n", totalcost);
fprintf(out, "Room will cost the most to carpet\n\n" );
printf("\n\nNow closing file...\n");
fclose(in);
fclose(out);
return 0;
}