Learn More Way

Problem :

Calculate Profit or Loss

Calculate Profit or Loss.

যা শিখবো:

ধাপে ধাপে ব্যাখ্যা:

Step 1: ইউজার ইনপুট নেওয়া।

scanf() দিয়ে costPrice এবং sellingPrice ইনপুট নেওয়া হবে।

Step 2: Decision Making Logic.

C
if(sellingPrice > costPrice) → Profit  
else if(sellingPrice < costPrice) → Loss  
else → No Profit, No Loss

Step 3: Profit বা Loss হিসাব করা এবং তা প্রিন্ট করা।

উদাহরণ:

C
#include <stdio.h>

int main() {
    float costPrice, sellingPrice, amount;

    printf("ক্রয়মূল্য (Cost Price) লিখুন: ");
    scanf("%f", &costPrice);

    printf("বিক্রয়মূল্য (Selling Price) লিখুন: ");
    scanf("%f", &sellingPrice);

    if(sellingPrice > costPrice) {
        amount = sellingPrice - costPrice;
        printf("লাভ হয়েছে: %.2f টাকা", amount);
    }
    else if(sellingPrice < costPrice) {
        amount = costPrice - sellingPrice;
        printf("ক্ষতি হয়েছে: %.2f টাকা", amount);
    }
    else {
        printf("না লাভ হয়েছে, না ক্ষতি হয়েছে।");
    }

    return 0;
}

আউটপুট উদাহরণ:

উদাহরণ ১:

C
ইনপুট:
ক্রয়মূল্য (Cost Price) লিখুন: 1000  
বিক্রয়মূল্য (Selling Price) লিখুন: 1200

আউটপুট:
লাভ হয়েছে: 200.00 টাকা

উদাহরণ ২:

C
ইনপুট:
ক্রয়মূল্য (Cost Price) লিখুন: 1500  
বিক্রয়মূল্য (Selling Price) লিখুন: 1200

আউটপুট:
ক্ষতি হয়েছে: 300.00 টাকা

উদাহরণ ৩:

C
ইনপুট:
ক্রয়মূল্য (Cost Price) লিখুন: 500  
বিক্রয়মূল্য (Selling Price) লিখুন: 500

আউটপুট:
না লাভ হয়েছে, না ক্ষতি হয়েছে।

ব্যাখ্যা:

©2025 Linux Bangla | Developed & Maintaind by Linux Bangla.