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