0
hey guys !! my professor want me to create a c++ program using nested if .. can u please help . I am a beginner
c++ program using nested if
5 odpowiedzi
+ 2
You can try making a program somewhat like this:
Get user input for experience of the person
Get user input for what is the persons' salary
// program
if(exp<3) // if exp is less than 3
if(sal<5000) // if salary is less than 5000
cout<<"Salary ="<<sal+bon*2;
if(exp>3)
if(sal>5000)
cout<<"Salary ="<<sal+bon*3;
// You can expand your program in this way
// keep on adding conditions
// all the best 👍
+ 2
You can also make a program to find maximum number out of three in following way:
#include<iostream>
using namespace std;
int main()
{
int a,b,c;
cout<<"Enter any three numbers:";
cin>>a>>b>>c;
if (a>b)
{
if(a>c)
{
cout<<" Maximum number is:"<<a<<endl;
return 0;
}
}
if (b>a)
{
if(b>c)
{
cout<<"Maximum number is :"<<b;
return 0;
}
}
cout<<"Maximum number is :"<<c;
return 0;
}
however, There are many ways to find maximum number other than this but it is using nested if.
+ 1
thank u both of u
+ 1
really a great help
+ 1
you're welcome