Coding Practice

Write a C program to calculate profit or loss

Calculate Profit or Loss
Sample Output
Purchase Price: 143

Selling Price: 150

Profit!

Process returned 0 (0x0)   execution time : 8.603 s
Press any key to continue.
Source Code
#include<stdio.h>
 
int main()
{
    int buy, sell;
 
    printf("Purchase Price: ");
    scanf("%d", &buy);
    printf("\nSelling Price: ");
    scanf("%d", &sell);
 
    if(buy < sell)
    {
        printf("\nProfit!\n");
    }
    else if(sell == buy)
    {
        printf("\nNo Loss No Profit.\n");
    }
    else
    {
        printf("\nLoss!\n");
    }
}
Sample Output
Purchase Price: 150

Selling Price: 140

Loss!

Process returned 0 (0x0)   execution time : 12.151 s
Press any key to continue.

No comments:

Post a Comment

Change Theme
X