Question:
If cost price and selling price of an item is input through the keyboard, write a program to determine whether the seller has made profit or incurred loss. Also determine how much profit he made or loss incurred.
Here is my code:
#include <stdio.h>
int main() {
    int x, y, z, b, n;
    char k = '%';
    char r = '$';
    printf("Enter cost of item:-");
    scanf("%d", &x);
    printf("Enter selling price of item:-");
    scanf("%d", &y);
    if (x < y) {
        n = y - x;
        z = 100 / x;
        b = n / z;
        printf("You made %d%c profit \n", b, k);
        printf("or\n");
        printf("%d %c profits\n", n, r);
    }
    if (x > y) {
        n = y - x;
        z = 100 / x;
        b = n / z;
        printf("You made %d%c loss \n", b, k);
        printf("or\n");
        printf("%d %c loss\n", n, r);
    }
    return 0;
}
Hey I'm new in C programming knows basic only. Today I'm learning if / else and I try to solve this question.
But my code not giving any error and warning. It takes input and after its end  my if not working.
please Help:(
 
     
    