Anda di halaman 1dari 6

Name:- Krunal N. Gandhi.

Std.:-XI Science.
Roll No.:17.

(1) Write a C++ Program to input salary. If salary is more than


10000/- , calculate DA-75%, HRA-25%, PF-12.5%., Otherwise
calculate DA-50%, HRA-25%, PF-12.5%.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
double gs,s,pf,hra,da,d1;
cout<<Enter Salary:;
cin>>s;
da=((s>10000)?75:50;
da1=da*s/100;
cout<<DA:<<da1;
hra=25*5/100;
cout<<HRA:<<hra;
pf=12.5*s/100;
cout<<PF:<<pf;
gs=s+da1+hra-pf;
cout<<Gross Salary:<<gs;
getch();
}

(2) Write a program to input three integers and print the smallest
number.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
double a,b,c,d;
cout<<Enter 1st Value:;
cin>>a;
cout<<Enter 2nd Value:;
cin>>b;
cout<<Enter 3rd Value:;
cin>>c;
d=(a<b&&a<c)?a:(b<a&&b<c)?b:c;
cout<<The Smallest No. is:<<d;
getch();
}

(3) Write a program to input principle amount and rate of interest.


If the rate of interest is more than 25%, calculate the simple interest
with 5 years. Otherwise calculate it with 2 years.
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
double p,r,t,si;
cout<<Enter Principal amount:;
cin>>p;
cout<<Enter Rate of Interest:;
cin>>r;
t=((r>25)?5:2);
cout<<Time:<<t;
si=p*r*t/100;
cout<<Simple Interest is:<<si;
getch();
}

(4) Write a C++ program to input choice (1 or 2). If choice is 1,


print the (a+b)2 were a=10,b=5 otherwise print (a+b+c)3 were a=5,
b=6, c=7.
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
double a,b;
cout<<1.(a+b)2 ;
cout<<2.(a+b+c)3 ;
cout<<Enter your choice:;
cin>>a;
e=((d==1)?pow((10+5),2):pow((5+6+7),3);
cout<<The Answer is:<<b;
getch();
}

(5)
Write a C++ program An electricity board charges according
to following rates:
For the first 150 units 65 paise per unit and meter charges are
120/-, Otherwise 75 paise per unit meter charges are 150/-.

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
double u,a,b,c;
cout<<Enter the no. of units consumed:;
cin>>u;
a=((u<150?0.65:0.75);
b=((u<150)?120:150);
c=u*a+b;
cout<<Total Bill:<<c;
getch();
}

Anda mungkin juga menyukai