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;
}