Powered By Blogger

Friday, April 20, 2012

Program : 4



PROGRAM - 4(a)


 If cost price and selling price of an item is input through the keyboard, write program to determine whether the seller has made profit or incurred loss. Also determine how much profit or loss he incurred in percentage.

Program:

#include<stdio.h>
#include<conio.h>
void main()
{
     float cp,sp,profit,loss,pper,lper;
     clrscr();
     printf("Enter values of cp,sp : ");
     scanf("%f %f",&cp,&sp);
     if (cp>sp)
     {
           loss=cp-sp;
           printf("\n Loss= rs.%4.2f",loss);
           lper=(loss/cp)*100;
           printf("\n Loss percentage = %4.2f",lper);
     }
     else
     {
           profit=sp-cp;
           printf("\n Profit = rs.%4.2f",profit);
           pper=(profit/cp)*100;
           printf("\n Profit percentage = %4.2f",pper);
     }
     getch();
}
/*   OUTPUT:enter the values of cp,sp   8000, 6000
                loss
                losspercentage=100.000000
*/



 PROGRAM - 4(b)

 An insurance company calculates premium as follows:

ü  If a person’s health is excellent and the person is between 25 and 35 years of age and lives in a city and is a male then the premium is Rs.4 per thousand and the policy amount cannot exceed Rs.2 Lacks.
ü  If a person is satisfies all the above conditions and is female then the premium is Rs. 3 per thousand and the policy amount cannot exceed Rs. 1 Lack.
ü  If a person’s health is poor and the person is between 25 and 35 years of age and lives in a village and is a male then premium is Rs. 6 per thousand and the policy cannot exceed Rs. 10000.
ü  In all other cases the person is not insured.

Write a program to determine whether the person should be insured or not, his/her premium rate and maximum amount for which he/she can be insured. 


Program:

#include<stdio.h>
#include<conio.h>
void main()
{
     int age=0;
     char health=0,res=0,sex=0;
     clrscr();
     printf("\n enter the follwing details :\n\n ");
     printf("\n health (y or n):\t");
     scanf(" %c",&health);
     printf("\n sex (m or f):\t");
     scanf(" %c",&sex);
     printf("\n residence (c or v):\t");
     scanf(" %c",&res);
     printf("\n age : \t ");
     scanf(" %d",&age);
     if (health=='y' && (age>=25 && age<=35)
             && res=='c' && sex=='m')
     {
           printf("\n person is insured");
           printf("\n premium is rs.4/- 
                                 per thousand");
           printf("\n policy amount cannot exceed
                        Rs. 2 lakhs");
     }
     else if (health=='y' && (age>=25 && age<=35) 
             &&  res=='v' && sex=='f')
     {
           printf("\n person is insured");
           printf("\n premium is rs.3/- 
                                 per thousand");
           printf("\n policy amount cannot 
                                  exceed rs. 1 lakh");
     }
     else if (health=='n' && (age>=25 && age<=35)
                    && res=='c' &&sex=='m')
     {
           printf("\n person  is insured");
           printf("\n premiun is rs.6/- 
                     per thousand");
           printf("\n policy amount cannot
                            exceed rs. 10000");
     }
     else
           printf("person is not insured");
     getch();
}

No comments:

Post a Comment