Hello sir below is my code can you plz explain it line by line in details #include<stdio.h> #include<stdlib.h> #include<stdbool.h> #include<string.h> #include<time.h> struct...

50.1K

Verified Solution

Question

Programming

Hello sir below is my code can you plz explain it line by linein details

#include

#include

#include

#include

#include

struct patient {

int id;

int age;

bool annualClaim;

int plan;

char name[30];

char contactNum[15];

char address[50];

};

#define MAX_LENGTH 500

struct patient patients[100];

int patientCount = 0;

struct claim {

int id;

int claimedYear;

int amountClaimed;

int remaininigAmount;

};

struct claim claims[100];

void subscribe()

{

system(\"cls\");

patients[patientCount].id = patientCount + 1;

printf(\"Enter age: \");

scanf(\"%d\", & patients[patientCount].age);

printf(\"\n\n%-25sHealth Insurence Plan\n\n\", \" \");

printf(\"-----------------------------------------------------------------------------------------------\n\");

printf(\"|%-30s|%-20s|%-20s|%-20s|\n\", \" \", \"Plan 120(RM)\", \"Plan150(RM)\", \"Plan 200(RM)\");

printf(\"-----------------------------------------------------------------------------------------------\n\");

printf(\"|%-30s|%-20d|%-20d|%-20d|\n\", \"Monthly Premium\", 120,150, 200);

printf(\"-----------------------------------------------------------------------------------------------\n\");

printf(\"|%-30s|%-20d|%-20d|%-20d|\n\", \"Annual Claim Limit\",120000, 150000, 200000);

printf(\"-----------------------------------------------------------------------------------------------\n\");

printf(\"|%-30s|%-20d|%-20d|%-20d|\n\", \"Lifetime Claim Limit\",600000, 750000, 1000000);

printf(\"-----------------------------------------------------------------------------------------------\n\");

printf(\"\n\n%-25sAge Group and Health Insurence Plan\n\n\", \"\");

printf(\"-----------------------------------------------------------------------------------------------\n\");

printf(\"|%-30s|%-25s%-30s\n\", \"Types of Claim\", \" \",\"Eligibility Amount\");

printf(\"-----------------------------------------------------------------------------------------------\n\");

printf(\"|%-30s|%-20s|%-20s|%-20s|\n\", \" \", \"Plan 120(RM)\", \"Plan150(RM)\", \"Plan 200(RM)\");

printf(\"-----------------------------------------------------------------------------------------------\n\");

printf(\"|%-30s|%-20s|%-20s|%-20s|\n\", \"Room Charges\", \"120/day\",\"150/day\", \"200/day\");

printf(\"-----------------------------------------------------------------------------------------------\n\");

printf(\"|%-30s|%-20s|%-20s|%-20s|\n\", \"Intensive Care Unit\",\"250/day\", \"400/day\", \"700/day\");

printf(\"-----------------------------------------------------------------------------------------------\n\");

printf(\"|%-30s|%-20s|%-20s|%-20s|\n\", \"Hospital Supplies andServices\", \" \", \" \", \" \");

printf(\"-----------------------------------------------------------------------------------------------\n\");

printf(\"|%-30s|%-60s|\n\", \"Surgical Fees\", \"As charged Sbject toapproval by ZeeMediLife\");

printf(\"-----------------------------------------------------------------------------------------------\n\");

printf(\"|%-30s|%-20s|%-20s|%-20s|\n\", \"Other Fees\", \" \", \" \", \"\");

printf(\"-----------------------------------------------------------------------------------------------\n\n\");

int ch;

do {

printf(\"Select a Claim Limit Type\n1-Annual Claim Limit2-Lifetime Claim Limit: \");

scanf(\"%d\", & ch);

} while (ch < 1 || ch > 2);

if (ch == 1)

patients[patientCount].annualClaim = true;

else

patients[patientCount].annualClaim = false;

do {

printf(\"Select a plan\n1-Plan120 2-Plan150 3-Plan200: \");

scanf(\"%d\", & ch);

} while (ch < 1 || ch > 3);

patients[patientCount].plan = ch;

printf(\"Enter Name: \");

scanf(\"%s\", & patients[patientCount].name);

printf(\"Contact Number: \");

scanf(\"%s\", & patients[patientCount].contactNum);

printf(\"Enter Address: \");

scanf(\"%s\", & patients[patientCount].address);

FILE * fp;

fp = fopen(\"patients.txt\", \"a\");

fprintf(fp, \"%d,%s,%d,%d,%d,%s,%s\n\", patients[patientCount].id,patients[patientCount].name, patients[patientCount].age,patients[patientCount].annualClaim, patients[patientCount].plan,patients[patientCount].contactNum,patients[patientCount].address);

fclose(fp);

time_t s;

struct tm * currentTime;

s = time(NULL);

currentTime = localtime( & s);

claims[patientCount].id = patients[patientCount].id;

claims[patientCount].amountClaimed = 0;

claims[patientCount].claimedYear = currentTime -> tm_hour +1900;

if (patients[patientCount].annualClaim ==true)

{

if (patients[patientCount].plan == 1)

claims[patientCount].remaininigAmount = 120000;

else if(patients[patientCount].plan == 2)

claims[patientCount].remaininigAmount = 150000;

else

claims[patientCount].remaininigAmount = 200000;

} else

{

if (patients[patientCount].plan == 1)

claims[patientCount].remaininigAmount = 600000;

else if(patients[patientCount].plan == 2)

claims[patientCount].remaininigAmount = 750000;

else

claims[patientCount].remaininigAmount = 1000000;

}

patientCount++;

fp = fopen(\"claims.txt\", \"a\");

if (fp == NULL)

printf(\"File Dont exist\");

fprintf(fp, \"%d,%d,%d,%d\n\", claims[patientCount].id,claims[patientCount].claimedYear,claims[patientCount].amountClaimed,claims[patientCount].remaininigAmount);

fclose(fp);

system(\"pause\");

}

Answer & Explanation Solved by verified expert
4.1 Ratings (559 Votes)
I HAVE COMMENTED EACH LINE EXPLANATION AGIANTS EACH LINE YOU CAN EXECUTE IT include including stabdard input output include including standard library include include include struct patient defining a structure patient with following fields int id an id of integer type int age age of integertpye bool annualClaim annualvlaim of boolean type int plan plan of integer type char name30 an name array of char type with size 30 char contactNum15 a contactnum array of char type with size 15 char address50 an address array of char type with size 50 define MAXLENGTH 500 defining maxlenght tp 500 global struct patient patients100 defining a object of structure patient type with name patients and size 100 int patientCount 0 intialising patient count to 0 struct claim defining a structure claim with following fields int id an id of integer type int claimedYear a claimedyear of integer type int amountClaimed aa amountclaimed of integer type int remaininigAmount a remainingAmount of integer type struct claim claims100 defining a object of structure claim type with name claims and size 100 void subscribe defining a function of subscribe name systemcls clearing tha system patientspatientCountid patientCount 1 entering the value to id of structure patients patients object printfEnter age taking input for age from userkeyboard scanfd patientspatientCountage entering the value to    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students