Problems
Example 1: Write a program to accept two numbers and find maximum
number and display it ?
Answer: #include<iostream.h>
#include<conio.h>
Void
main()
{
Clrscr();
Int n1,n2,max;
Cout<<βEnter any two numbersβ;
Cin>>n1>>n2;
If(n1>n2)
{
Cout<<n1<<β is maximum numberβ;
}
Else
{
Cout<<n2<<β is maximum numberβ;
}
getch();
}
Example 2: Write a program to accept two numbers and find minimum number
and display it ??
Answer: #include<iostream.h>
#include<conio.h>
Void
main()
{
Clrscr();
Int n1,n2,min;
Cout<<βEnter any two numbersβ;
Cin>>n1>>n2;
If(n1<n2)
{
Cout<<n1<<β is minimum numberβ;
}
Else
{
Cout<<n2<<β is minimum numberβ;
}
getch();
}
Example 3 :write a program to accept a number from user and check it is
odd or even ??
Answer: #include<iostream.h>
#include<conio.h>
Void
main()
{
Clrscr();
Int n;
Cout<<βEnter a numbersβ;
Cin>>a;
If(a%2==0)
{
Cout<<n1<<β given memories evenβ;
}
Else
{
Cout<<n2<<β given number is oddβ;
}
getch();
}
Example 4: write a program to accept bill from user and find out discount if bill >=50000 and discount
is 15% otherwise discount is 10%
Answer: #include<iostream.h>
#include<conio.h>
Void
main()
{
Clrscr();
Int bl,discount;
Cout<<βEnter bill amountβ;
Cin>>bl;
If(bl>=50000)
{
Discount=
(bl*15)/100;
}
Else
{
Discount= (bl*10)/100;
}
Cout<<βDiscount
is β<<discount;
getch();
}
Example 5: Write a program to accept bill and find G.S.T if bill >=50000 then G.S.T is 20% otherwise
G.S.T is 10% ??
Answer: #include<iostream.h>
#include<conio.h>
Void
main()
{
Clrscr();
Int bl,gst;
Cout<<βEnter bill amountβ;
Cin>>bl;
If(bl>=50000)
{
Discount=
(bl*20)/100;
}
Else
{
Discount= (bl*10)/100;
}
Cout<<βTotal
G.S.T is β<<gst;
getch();
}
Example 6: Write a program to accept salary from user and calculate income tax if salary >=30000
then 8% otherwise 4%
Answer: #include<iostream.h>
#include<conio.h>
Void
main()
{
Clrscr();
Int s,it;
Cout<<βEnter salary amountβ;
Cin>>s;
If(s>30000)
{
it= (s*8)/100;
}
Else
{
it= (s*4)/100;
}
Cout<<βIncome
tax is β<<it;
getch();
}
Example 7: Write a program to accept salary from user and find out the bonus if salary 100000 then
25% of salary otherwise 10 of salary
Answer: #include<iostream.h>
#include<conio.h>
Void
main()
{
Clrscr();
Int s,b;
Cout<<βEnter salary amountβ;
Cin>>s;
If(bl>=100000)
{
b= (s*25)/100;
}
Else
{
b= (s*10)/100;
}
Cout<<βBonus
is β<<b;
getch();
}
0 Comments