Dremendo Tag Line

Check if the seller has made profit or not in C++

if else - Question 3

In this question, we will see how to input cost price and sale price and check if the seller has made a profit or not in C++ programming using the if else statement. To know more about if else statement click on the if else statement lesson.

Q3) Write a program in C++ to input cost price and sale price and check if seller has made profit or not.

Program

#include <iostream>
#include <conio.h>

using namespace std;

int main()
{
    int cp,sp;
    cout<<"Enter cost price ";
    cin>>cp;
    cout<<"Enter sale price ";
    cin>>sp;
    if(sp>cp)
    {
        cout<<"The seller has made a profit";
    }
    else
    {
        cout<<"The seller has not made any profit";
    }
    return 0;
}

Output

Enter cost price 350
Enter sale price 465
The seller has made a profit
video-poster