Profit Loss - C Program

Profit Loss

 #include<stdio.h>
int main()
{
    float cp, sp;
    printf("Enter Cost Price :");
    scanf("%f",&cp);
    printf("Enter Selling Price :");
    scanf("%f",&sp);
    if (sp > cp)
            printf("Got Profit : %f", sp - cp);
    else if (cp > sp)
            printf("Got Loss :%f", cp - sp);
    else
            printf("Got No Profit No Loss");
    return 0;
}

Output - Profit Loss

Enter Cost Price :1000                                                                                                
Enter Selling Price :2000                                                                                             
Got Profit : 1000.000000  
Compile and Run Online