Q-20.Write a program that takes buying price and selling price of a product as input and find out the profit or loss of the product.

0
একটি প্রোগ্রাম লিখুন যা ইনপুট হিসাবে একটি পণ্য মূল্য এবং বিক্রয় মূল্য গ্রহণ করে এবং মুনাফা খুঁজে বের করে, বা পণ্য ক্ষতি।


  1. #include <stdio.h>

  2. int main()
  3. {
  4.     int cp,sp, amt;

  5.     /* Input cost price and selling price of a product */
  6.     printf("Enter cost price: ");
  7.     scanf("%d", &cp);
  8.     printf("Enter selling price: ");
  9.     scanf("%d", &sp);

  10.     if(sp > cp)
  11.     {
  12.         /* Calculate Profit */
  13.         amt = sp - cp;
  14.         printf("Profit = %d", amt);
  15.     }
  16.     else if(cp > sp)
  17.     {
  18.         /* Calculate Loss */
  19.         amt = cp - sp;
  20.         printf("Loss = %d", amt);
  21.     }
  22.     else
  23.     {
  24.         /* Neither profit nor loss */
  25.         printf("No Profit No Loss.");
  26.     }

  27.     return 0;
  28.    }


  •         Picture shown through



please try..



Post a Comment

0Comments
Post a Comment (0)