Skip to content

Instantly share code, notes, and snippets.

@wakoliVotes
Created May 5, 2022 19:25
Show Gist options
  • Save wakoliVotes/49a794faec573aecaa02e9a48a414786 to your computer and use it in GitHub Desktop.
Save wakoliVotes/49a794faec573aecaa02e9a48a414786 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main()
{
// Declaring variables
int Qty, disc = 0;
float rate, totalExp;
// Getting input values and storing them
printf("Enter Qunatity and Rate: ");
scanf("%d %f", &Qty, &rate);
// Now adding if statement to the problem
if (Qty > 100)
disc = 10; // Discount is in percent
// Calculating total
totalExp = (Qty*rate) - (Qty*rate*disc/100); // Divided by 100 for %
printf("The Total Expense is: %.2f", totalExp);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment