Computer Science, asked by nehakausar222, 7 months ago

"Write program in C to check profit and loss if the selling price is greater than cost price then calculate the profit else calculate the loss using if condition. " need help please answer this question.

Answers

Answered by akashkumar02042001
1

Answer:

Formula to calculate cost price if selling price and profit percentage are given: CP = ( SP * 100 ) / ( 100 + percentage profit). Formula to calculate cost price if selling price and loss percentage are given: CP = ( SP * 100 ) / ( 100 – percentage loss ).

Answered by sougatap57
0

Answer:

The Language used:-

1.c program

2.c++ program

C program

#include <stdio.h>

int main()

{

int sp,cp,amt;

printf("enter the cost price and sell price");

scanf("%d%d",&cp,&sp);

if(sp>cp)

{

    amt=sp-cp;

    printf("profits=%d",amt);

}

else if(cp>sp)

{

    amt=cp-sp;

    printf("loss=%d",amt);

}

 

   return 0;

}

Output

enter the cost price and sell price 250 260

profits 10

c++ program.

#include <iostream>

using namespace std;

int main()

{

 int sp,cp,amt;

 cout<<"enter the cost price and sell price";

 cin>>cp>>sp;

 if(sp>cp)

 {

     amt=sp-cp;

     cout<<"it is profit"<<amt;

 }

 else if(cp>sp)

 {

     amt=cp-sp;

     cout<<"it is loss"<<amt;

 }

  return 0;

}

Output

enter the cost price and sell price 260 250

it is loss 10  

Similar questions