16. Write a Program to input salary and calculate bonus if salary<5000 then bonus is 500 else bonus is 1000.
Answer:
#include<iostream.h>
#include<conio.h>
Void main()
{
float salary,a,b;
clrscr();
cout<<"Enter the Salary:";
cin>>salary'
a=salary+500;
b=salary+1000;
if(salary<5000)
{
cout<<endl<<"Your salary is less than 5000";
cout<<endl<<"Bonus = 500\n";
cout<<endl<<"Total Salary="<<a;
}
else
{
cout<<endl<<"Your salary is greater than 5000";
cout<<endl<<"Bonus = 1000\n";
cout<<endl<<"Total Salary = "<<b;
}
getch();
}
Answer:
#include<iostream.h>
#include<conio.h>
Void main()
{
float salary,a,b;
clrscr();
cout<<"Enter the Salary:";
cin>>salary'
a=salary+500;
b=salary+1000;
if(salary<5000)
{
cout<<endl<<"Your salary is less than 5000";
cout<<endl<<"Bonus = 500\n";
cout<<endl<<"Total Salary="<<a;
}
else
{
cout<<endl<<"Your salary is greater than 5000";
cout<<endl<<"Bonus = 1000\n";
cout<<endl<<"Total Salary = "<<b;
}
getch();
}
...................................................................................................................................................................
17. Write a Program to input salary calculate HRA,DA, Total Salary if Salary<5000 HRA is 5% of salary and DA is 7% of salary if salary between 5000-10000 HRA is 6% of salaryl and DA is 8% salary calculate total salary.
Answer:
#include<iostream.h>
#include<conio.h>
Void main()
{
float sal,hra1,hra2,da1,da2;
clrscr();
cout<<"Enter the Basic Salary:";
cin>>sal;
hra1=sal*5/100;
da1=sal*7/100;
hra2=sal*6/100;
da2=sal*8/100;
if(sal<5000)
{
cout<<endl<<"HRA= "<<hra1;
cout<<endl<<"DA= "<<da1;
cout<<endl<\n Total Salary="<<sal+hra1+da1;
}
else if(sal>5000<10000)
{
cout<<endl<<HRA= "<<hra2;
cout<<endl<<DA= "<<da2;
cout<<endl<<"\n Total Salary="<<sal+hr2+da2;
}
getch();
}
...................................................................................................................................................................
18. Write a Program to input two numbers and swap them using third variable.
Answer:
#include<iostream.h>
#include<conio.h>
Void main()
{
int a,b,t;
cout<<"Enter a,b";
cin>>a>>b;
cout<<a<<" "<<b<<;
t=a;
a=b;
b=t;
cout<<a<<" "<<b<<"\";
getch();
}
...................................................................................................................................................................
19. Write a Program to swap two number without using third variable.
Answer:
#include<iostream.h>
#include<conio.h>
Void main()
{
int a,b;
cout<<"Enter a,b";
cin>>a>>b;
cout<<a<<" "<<b<<;
a=a+b;
b=a-b;
a=a-b;
cout<<a<<" " <<b<<\n";
getch();
}
...................................................................................................................................................................
20. Write a Program to input a number if the number is even then power 4 else power 5.
Answer:
#include<iostream.h>
#include<conio.h>
Void main()
{
cout<<"Enter the Number:";
cin>>num;
fourth = num*num*num*num;
five = num*num*num*num*num;
if(num%2 == 0)
{
cout<<"power fourth="<<fourth;
}
else
{
cout<<"power five="<<five;
}
getch();
}
*********************************************************************************
0 comments:
Post a Comment