Thursday, October 8, 2009

Determine if eligible for premium & Policy

/*An Insurance company follows rules to calculate premium

1)If a person's health is excellent and the person is btw. 25 & 35 years of age and lives in city and is a male then the premium is Rs 4 per thousand and his policy amount cannot exceed Rs 2 lakhs.

2)If a person satisfies all the above conditions except that the sex is female then the premium is Rs 3 per thousand and her policy amount cannot exceed Rs 1 lakh.

3)If a person's health is poor and the person is btw. 25-35 and lives in village and is male ,the premium is Rs 6 per thousand and his policy cannot exceed Rs 10,000

4)In all other cases the person is not insured

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

#Solution
=======

#include <stdio.h>
int main(void)
{
int age,pre,policy_amt;
char sex,live,health;
printf("Enter your age : ");
scanf("%d",&age);
if ( age <= 35 && age >= 25)
{
printf("\nPl.enter your health status ( h/p- h(healthy),p(poor health): ");
scanf(" %c",&health);
printf("\nDo you live in city/Village(c=city)(v=village): ");
scanf(" %c",&live);
printf("\nAre you Male/Female(m=male,f=female : ");
scanf(" %c",&sex);

if ( health == 'h')
{
if ( sex == 'm'&& live == 'c')
printf("\nYou are opt for Rs 4/- Preminum over 1000 Rs & Policy not greater than 2 lakh");
else if ( sex == 'f'&& live == 'c')
printf("\nYou are opt for Rs 3/- Preminum over 1000 Rs & Policy not greater than 1 lakh");
}
else if ( live == 'v' && sex == 'm')
printf("\nYou are opt for Rs 6/- Preminum over 1000 Rs & Policy not greater than 10,000 Rs/-");

if ( sex == 'm' && live == 'c' && health == 'p')
printf("\nSorry no premium or Policy for you");
if ( sex == 'm' && live == 'v' && health == 'h')
printf("\nSorry no premium or Policy for you");
if ( sex == 'f' && live == 'v' && ((health == 'h') || (health == 'p' )))
printf("\nSorry no premium or Policy for you");
if ( sex == 'f' && live == 'c' && health == 'p')
printf("\nSorry no premium or Policy for you");
}

else
printf("\nYou are not eligible for Premium or Policy");

return 0;
}






Determine character input if its Capital,small,decimal or special character

/*Any character is entered through the keyboard ,write a program to determine whether the character entered is a capital letter,a small case letter,a digit or a special symbol

Following is Range of Ascii values for various characters:-

Characters                                           Ascii Values

A-Z                                                        65-90

a-z                                                         97-122

0-9                                                         48-57

Special symbols                                   0-47,58-64,91-96,123-127 */


#1 Solution ( With Value of ASCII characters as integer as input) :-

========================================

#include <stdio.h>
int main(void)
{
int i;
printf("Enter a character to determine its type : ");
scanf("%d",&i);


if ( (i <= 90) && (i >= 65))
printf("\nIts %c whose value is %d ,which belongs to A-Z character type",i,i);
else if ( i <= 122 && i >= 97 )
printf("\nIts %c whose value is %d,which belongs to a-z character type",i,i);
else if ( i <= 57 && i >= 48 )
printf("\nIts %c whose value is %d,which belongs to 0-9 character type",i,i);
else if (( i <= 47 && i >= 0) || ( i <= 64 && i >= 58) || ( i >= 91 && i <= 96) || ( i <= 127 && i >= 123))
printf("\nIts %c whose value is %d,which belongs to specific symbols",i,i);
return 0;
}
 

#2 Solution ( With ASCII Characters as input ) :-

==============================

#include <stdio.h>
int main(void)
{
char i;

printf("Enter a character to determine its type :");
scanf("%c",&i);


if (( i <= 'Z') && (i >= 'A'))
printf("\nIts %c whose value is %d ,which belongs to A-Z character type",i,i);
else if (( i >= 'a') && (i <= 'z' ))
printf("\nIts %c whose value is %d,which belongs to a-z character type",i,i);
else if ( (i >= '0') && (i <= '9'))
printf("\nIts %c whose value is %d,which belongs to 0-9 character type",i,i);
else
printf("\nIts %c whose value is %d,which belongs to *special symbols*",i,i);
return 0;
}


Wednesday, April 15, 2009

Calculate gross salary

/*If his basic salary is less than Rs. 1500, then HRA = 10% of basic
salary and DA = 90% of basic salary. If his salary is either equal to
or above Rs. 1500, then HRA = Rs. 500 and DA = 98% of basic
salary. If the employee's salary is input through the keyboard write
a program to find his gross salary.*/

Solution Code:-
=========


#include <stdio.h>
int main(void)
{
int bs;
float hra,da,gross;
printf("Enter Basic Salary : ");
scanf("%d",&bs);
if ( bs < 1500 )
{
hra = bs * 10 / 100;
da = bs * 90 /100;

}

else
{
hra = 500 ;
da = bs * 98 /100;
}

gross = hra + da + bs ;
printf("\n Your gross salary is %f",gross);
return 0;
}

Tuesday, April 14, 2009

Print a five digit number by adding one to each of its digits

/*If a five-digit number is input through the keyboard, write a
program to print a new number by adding one to each of its
digits. For example if the number that is input is 12391 then
the output should be displayed as 23402.*/


Solution Code :-
=========

#include <stdio.h>
int main(void)
{
int i,temp = 0;
printf("Enter a +ve 5 digit number :");
scanf("%d",&i);
if (( i <= 99999 ) && ( i > 9999 ))
{
printf(" %d",(i/10000) + 1);
printf(" %d",((( i/100) % 100)/10) + 1);
printf(" %d",(( i/100) % 10 ) + 1);
printf(" %d",((i % 100) / 10) + 1 );
printf(" %d",(i % 10) + 1);
}
else
printf("\n Pl.enter +ve five digit number");
return 0;
}

Monday, April 13, 2009

Calculate price of single item

*If the total selling price of 15 items and the total profit earned
on them is input through the keyboard, write a program to
find the cost price of one item.*/

/*Here the query maker ,I suppose seeks for groce price rate of one item ,as groce profit & groce selling price is sought out
sin => single item groce price ; procin => profit on single item ;con => conjugal price (profit + single item price)
*/

Solution Code :-
==========


#include <stdio.h>
int main(void)
{
int price,profit,sin,prosin,con;
printf("Enter price of 15 items : ");
scanf("%d",&price);
printf("\nEnter profit made on 15 items : ");
scanf("%d",&profit);
sin = price / 15 ;
prosin = (profit / 15) - sin;
con = sin + prosin ;
printf("\nSingle item cost is %d",sin);
printf("\nSingle item profit is %d",prosin);
printf("\nSingle item cost price is %d",con);
return 0;
}

Sunday, April 12, 2009

Find total number of currency notes of each 10,50,100 denominations

/*A cashier has currency notes of denominations 10, 50 and
100. If the amount to be withdrawn is input through the
keyboard in hundreds, find the total number of currency notes
of each denomination the cashier will have to give to the
withdrawer.*/

Solution Code:-
=========

#include <stdio.h>
int main(void)
{
int amt;
printf("Enter the amount to withdraw : ");
scanf("%d",&amt);
printf("\nNotes of 100 required are %d", amt/100);
printf("\nWhile Notes of 50 required are %d", ((amt % 100)/50));
printf("\nAnd notes of 10 required are %d",((amt % 100)% 50)/10);
return 0;
}

Percentage of Literate & Illiterate along with men & women in town

/*In a town, the percentage of men is 52. The percentage of
total literacy is 48. If total percentage of literate men is 35 of
the total population, write a program to find the total number
of illiterate men and women if the population of the town is
80,000*/

Solution Code:-
===========
/*popmen = population of men,popwo = population of women ,literate women = ilwo,ilmen = ill-literate men,limen = literate men,liwo = literate women,li= literate men*/

#include <stdio.h>
int main(void)
{
int popmen,popwo,ilmen,ilwo,li,limen,liwo,total;
popmen = (80000 * 52)/100;
printf("\nTotal population of Men in town is %d out of 80000",popmen);
popwo = (80000 - popmen);
printf("\nTotal population of women in town is %d out of 80000",popwo);
li = ( 80000 * 48)/100;
printf("\nTotal literate population in town is %d",li);
limen = ( popmen * 35 )/100;
printf("\nTotal amount of literate Men are %d",limen);
ilmen = popmen - limen;
printf("\nTotal amount of Ill-literate Men are %d",ilmen);
liwo = li - limen ;
printf("\nTotal amount of Literate women is %d",liwo);
ilwo = popwo - liwo ;
printf("\n Total amount of Ill-literate women is %d",ilwo);

return 0;
}