#include <stdio.h>
int main() {
int number;
float price, discount, total;
printf("Are you number <1. Yes 2. No>:"); scanf("%d", &number);
printf("Enter the purchase price :"); scanf("%f", &price);
if ((number == 1) && (price >= 2000)) {
discount = price * 0.1;
total = price - discount;
} else if ((number == 1) && (price < 2000)) {
discount = price * 0.07;
total = price - discount;
} else if ((number == 2) && (price >= 1000)) {
discount = price * 0.05;
total = price - discount;
} else {
discount = 0;
total = price - discount;
}
printf("The purchase price = %.2f\n", price
); printf("Discount = %.2f\n", discount
); printf("Price after discount = %.2f\n", total
);
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgbWFpbigpIHsKICAgIGludCBudW1iZXI7CiAgICBmbG9hdCBwcmljZSwgZGlzY291bnQsIHRvdGFsOwoKICAgIHByaW50ZigiQXJlIHlvdSBudW1iZXIgPDEuIFllcyAyLiBObz46Iik7CiAgICBzY2FuZigiJWQiLCAmbnVtYmVyKTsKCiAgICBwcmludGYoIkVudGVyIHRoZSBwdXJjaGFzZSBwcmljZSA6Iik7CiAgICBzY2FuZigiJWYiLCAmcHJpY2UpOwoKICAgIGlmICgobnVtYmVyID09IDEpICYmIChwcmljZSA+PSAyMDAwKSkgewogICAgICAgIGRpc2NvdW50ID0gcHJpY2UgKiAwLjE7CiAgICAgICAgdG90YWwgPSBwcmljZSAtIGRpc2NvdW50OwogICAgfSBlbHNlIGlmICgobnVtYmVyID09IDEpICYmIChwcmljZSA8IDIwMDApKSB7CiAgICAgICAgZGlzY291bnQgPSBwcmljZSAqIDAuMDc7CiAgICAgICAgdG90YWwgPSBwcmljZSAtIGRpc2NvdW50OwogICAgfSBlbHNlIGlmICgobnVtYmVyID09IDIpICYmIChwcmljZSA+PSAxMDAwKSkgewogICAgICAgIGRpc2NvdW50ID0gcHJpY2UgKiAwLjA1OwogICAgICAgIHRvdGFsID0gcHJpY2UgLSBkaXNjb3VudDsKICAgIH0gZWxzZSB7CiAgICAgICAgZGlzY291bnQgPSAwOyAKICAgICAgICB0b3RhbCA9IHByaWNlIC0gZGlzY291bnQ7CiAgICB9CgogICAgcHJpbnRmKCIqKlxuIik7CiAgICBwcmludGYoIlRoZSBwdXJjaGFzZSBwcmljZSA9ICUuMmZcbiIsIHByaWNlKTsKICAgIHByaW50ZigiRGlzY291bnQgPSAlLjJmXG4iLCBkaXNjb3VudCk7CiAgICBwcmludGYoIlByaWNlIGFmdGVyIGRpc2NvdW50ID0gJS4yZlxuIiwgdG90YWwpOwoKfQ==
#include <stdio.h>
int main() {
int number;
float price, discount, total;
printf("Are you number <1. Yes 2. No>:");
scanf("%d", &number);
printf("Enter the purchase price :");
scanf("%f", &price);
if ((number == 1) && (price >= 2000)) {
discount = price * 0.1;
total = price - discount;
} else if ((number == 1) && (price < 2000)) {
discount = price * 0.07;
total = price - discount;
} else if ((number == 2) && (price >= 1000)) {
discount = price * 0.05;
total = price - discount;
} else {
discount = 0;
total = price - discount;
}
printf("**\n");
printf("The purchase price = %.2f\n", price);
printf("Discount = %.2f\n", discount);
printf("Price after discount = %.2f\n", total);
}