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 <stdio.h>
#include <conio.h>

int main()
{
    int cp,sp;
    printf("Enter cost price ");
    scanf("%d",&cp);
    printf("Enter sale price ");
    scanf("%d",&sp);
    if(sp>cp)
    {
        printf("The seller has made a profit");
    }
    else
    {
        printf("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