Created
November 10, 2014 18:58
-
-
Save nikAizuddin/2280902be1e1b6ad076e to your computer and use it in GitHub Desktop.
Example how to use function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
/********************* price_after_discount() *********************** | |
* Find the price of an item after the discount | |
* | |
* @argument1: price = item price. | |
* @argument2: discount = percentage of discount. | |
* | |
* @return: item price after discount | |
*/ | |
double price_after_discount(double price, double discount) | |
{ | |
double new_price = 0.00; | |
/** calculate price after discount */ | |
new_price = price - (price*(discount/100)); | |
return new_price; | |
} | |
int main(void) | |
{ | |
double coffee_price = 32.90; /* RM 32.90 */ | |
double coffee_discount = 75.00; /* 75.00% */ | |
double coffee_new_price = 0.00; | |
coffee_new_price = | |
price_after_discount(coffee_price, coffee_discount); | |
printf("Coffee: RM%.2f\n",coffee_new_price); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment