PROFIT OR LOSS in C programming

PROFIT OR LOSS
A fruitseller buys a dozen mangoes at Rs.X. He sells 1 mango at Rs.Y. Write a program to determine the profit or loss in Rs. for the fruitseller.

Input and Output Format:
Input consists of 2 floating point numbers which correspond to X and Y.
Refer sample input and output for formatting specifications. All floating point numbers are displayed correct to 2 decimal places.
All text in bold corresponds to input and the rest corresponds to output.

Sample Input and Output 1:
Enter the price of a dozen mangoes
60.0
Enter the price at which 1 mango is being sold
4
Loss : Rs.12.00

Sample Input and Output 2:
Enter the price of a dozen mangoes
60.0
Enter the price at which 1 mango is being sold
6
Profit : Rs.12.00

Sample Input and Output 3:
Enter the price of a dozen mangoes
60.0
Enter the price at which 1 mango is being sold
5
No profit nor loss

Image result for profit or loss in c

 Given program
01
  #include
02
int main()
03
{
04
  float x,y,z;
05
  printf("Enter the price of dozen mangoes\n");
06
  scanf("%f",&x);
07
  printf("Enter the price at which 1 mango is being sold\n");
08
  scanf("%f",&y);
09
  z=y*12;
10
  if(x==z)
11
    printf("No profit nor loss\n");
12
    else if(x>z)
13
      printf("Loss : Rs.%0.2f\n",(x-z));
14
      else if(x
15
        printf("Profit : Rs.%0.2f\n",(x+z));
16
        return 0;
17
}

04

 Actual Program


01
  #include
02
int main()
03
{

  float x,y,z;
05
  printf("Enter the price of dozen mangoes\n");
06
  scanf("%f",&x);
07
  printf("Enter the price at which 1 mango is being sold\n");
08
  scanf("%f",&y);
09
  z=y*12;
10
  if(x==z)
11
    printf("No profit nor loss\n");
12
    else if(x>z)
13
      printf("Loss : Rs.%0.2f\n",(x-z));
14
      else if(x
15
        printf("Profit : Rs.%0.2f\n",(x+z));
16
        return 0;
17

}

2 comments:

  1. Very nice & knowledgeable post all features are defined in a good way for more detail visit bitly.com thaks

    ReplyDelete
  2. Mr Benjamin went above and beyond their requirements to assist me with my loan which i used expand my pharmacy business,They were friendly, professional, and absolute gems to work with.I will recommend  anyone looking for loan to contact. 247officedept@gmail.com.WhatsApp ... + 19893943740.

    ReplyDelete