Write a C program to calculate profit and loss on a transaction

 



#include <stdio.h>
#include <conio.h>
void main()
{
    int cssum;
    printf("enter cost price: ");
    scanf("%d", &c);
    printf("enter selling price: ");
    scanf("%d", &s);
    if (c > s)
    {
        sum = c - s;
        printf("loss of %d"sum);
    }
    else if (s > c)
    {
        sum = s - c;
        printf("profit of %d"sum);
    }
    else
    {
        printf("Nither profit Nor loss!");
    }
    getch();
}


OUTPUT

Enter cost price: 500

Enter selling price: 700

Profit of 200


Follow our page for regular updates.

0 Comments