#include<stdio.h> int main() { int bs,da,hra,gs,bonus; printf("Enetr Base Salary"); scanf("%d",&bs); da=(40*bs)/100; hra=(80*da)/100; bonus=(25*hra)/200; gs=da+hra+bonus+bs; printf("%d",gs); return 0; }
Archive for the ‘Lab 9’ Category
11. Write a C program to find the gross salary of an employee Gross salary = base salary + DA + HRA+Bonus DA= 40 % of the base salary, HRA=80% of DA, and Bonus= 25% of HRA. Ask user to enter the base salary only.
Posted: September 15, 2012 in CSE Sem1, ECE Sem1, Lab 9, Lab 90
10. Write a C program to convert a given number of days into months and days.
Posted: September 15, 2012 in CSE Sem1, ECE Sem1, Lab 9, Lab 9#include<stdio.h> int main() { int d; printf("Enter days\n"); scanf("%d",&d); printf("%d years,%d months,%d days\n",d/365,(d%365)/30,(d%365)%30); return 0; }
9. Write a C program to determine the amount of compound interest to be paid by the borrower, if the principal amount, rate of interest, and tenure are entered by the user.
Posted: September 15, 2012 in CSE Sem1, ECE Sem1, Lab 9, Lab 9#include<stdio.h> #include<math.h> int main() { float p,rate,time,ci; printf("Enter principal amount : "); scanf("%f", &p); printf("Enter interest rate : "); scanf("%f", &rate); printf("Enter time period in year : "); scanf("%f", &time); ci=p*(pow((1+rate/100),time)-1); printf("\nCompound interest = %f",ci); return 0; }
8. Write a C program to determine the amount of interest to be paid by the borrower, if the principal amount, rate of interest, and tenure are entered by the user.
Posted: September 15, 2012 in CSE Sem1, ECE Sem1, Lab 9, Lab 9#include<stdio.h> int main( ) { float p,rate,n,si; printf("Enter principal amount : "); scanf("%f", &p); printf("Enter interest rate : "); scanf("%f", &rate); printf("Enter time period in year : "); scanf("%f", &n); si = p * n * rate / 100 ; printf("\nSimple interest = %f",si); return 0; }
6 & 7)Write a C program to determine the amount of profit or loss (in percentage) a seller has made, if the cost price and selling price of an article are entered by the user.
Posted: September 15, 2012 in CSE Sem1, ECE Sem1, Lab 9, Lab 9#include<stdio.h> int main() { float cp,sp,pro=0,loss=0,lossper,proper; printf("Enter sp and cp"); scanf("%f%f",&sp,&cp); if(cp>sp) { loss=cp-sp; } else if(sp>cp) { pro=sp-cp; } lossper=(loss/cp)*100; proper=(pro/cp)*100; if(cp>sp) { printf("Loss Percentage is %f",lossper); } else if(sp>cp) { printf("Profit Percentage is %f",proper); } return 0; }
5. Write a C program to print the sum of the cube of n natural numbers. the sum of cubes of first ‘n’ natural no`s- 1^3+2^3+3^3+4^3+……+n^3=(n^2 * (n+1)^2)/4
Posted: September 15, 2012 in CSE Sem1, ECE Sem1, Lab 9, Lab 9#include<stdio.h> int main() { int n,sum=0; printf("Enter Number"); scanf("%d",&n); sum=(n*n*(n+1)*(n+1))/4; printf("%d",sum); return 0; }
4. Write a C program to print the sum of the square of n natural numbers. the sum of squares of first ‘n’ natural no`s- 1^2+2^2+3^2+…..+n^2=n*(n+1)*(2n+1)/6
Posted: September 15, 2012 in CSE Sem1, ECE Sem1, Lab 9, Lab 9#include<stdio.h> int main() { int n,sum=0; printf("Enter Number"); scanf("%d",&n); sum=n*(n+1)*(2*n+1)/6 ; printf("%d",sum); return 0; }
3.Write a C program to print the sum of n natural numbers. the sum of first ‘n’ natural no`s- 1+2+3+…..+n=n*(n+1)/2
Posted: September 15, 2012 in CSE Sem1, ECE Sem1, Lab 9, Lab 9#include<stdio.h> int main() { int n,sum=0; printf("Enter Number"); scanf("%d",&n); sum=n*(n+1)/2; printf("%d",sum); return 0; }