Calculation of Discount using 'if' statement

This program is also yet another demonstration of using the 'if' statement.
Here, note that the initialization of the discount to zero is necessary for proper functioning of the program.


While purchasing certain items, a discount of 10% is offered if the quantity
purchased is more than 1000. If quantity and price per item are input
through the keyboard, write a program to calculate the total expenses.


#include<stdio.h>
main()

{
int qty,dis=0; /*initializing is required as if tot<1000, then discount is 0*/
float rate, tot;

printf ("Enter quantity and rate: ");
scanf ("%d %f", &qty, &rate);

if (qty>1000)
dis=10;

tot=(qty*rate) - (qty*rate*dis/100);

printf("Total expenses = Rs. %f", tot);

}


You can also download the File at:
Download File




Comments

Popular posts from this blog

C Program - Calculation of Area and Circumference of a Circle using Pointers

Matchstick Game using C Programming

Generation of Fibonacci Sequence using Recursion.