Tuesday, April 10, 2018

Best Life Insurance Plan


Program to compare best life insurance plan using an array.

Assumption: Best life insurance company plan is one which offers more risk cover for the specified premium.

Other parameters are also important to find best life insurance plan, but in this program only one parameter(risk cover) is considered.

#include<stdio.h>

int main()
{
 int riskcover[5], i, max, ans=1;
 char insurance_company[5][30];

 printf("Enter Risk Cover offered for Rs. 1000 premium by Each life insurance company.\n\n");

 for(i=0;i<5;i++) {
printf("Enter Name of Life Insurance Company- %d:",i+1);
scanf("%s",insurance_company[i]);
printf("Enter Risk Covered by Policy- %d:",i+1);
scanf("%d",&riskcover[i]);
 }
 //Logic to find Best Life Insurance Company.
 max=riskcover[0];
 for(i=0;i<5;i++) {
if(riskcover[i] >= max)
{
  max=riskcover[i];
  ans=i;
}
 }

 printf("Best Insurance Plan is offered by company:%s", insurance_company[ans]);
}

Output of program

Enter Risk Cover offered for Rs. 1000 premium by Each life insurance company.

Enter Name of Life Insurance Company- 1: AAA
Enter Risk Covered by Policy- 1:5000
Enter Name of Life Insurance Company- 2: BBB
Enter Risk Covered by Policy- 2:10000
Enter Name of Life Insurance Company- 3: CCC
Enter Risk Covered by Policy- 3:15000
Enter Name of Life Insurance Company- 4: DDD
Enter Risk Covered by Policy- 4:8000
Enter Name of Life Insurance Company- 5: EEE
Enter Risk Covered by Policy- 5:5000
Best Insurance Plan is offered by company: CCC

No comments:

Post a Comment