Control Statements (Conditional Control Statements)
If Conditions
Example 1: Write a program to compute net amount from the given quantity purchased and rate per quantity. Discount @10% is allowed if quantity purchased exceeds 100.
Net Amount = (Quantity Purchased x Rate Per Quantity) – Discount.
#include <stdio.h>
#include <conio.h>
void main()
{
int qty,rate;
float disc=0.0,net;
clrscr();
printf("\nENTER QUANTITY: ");
scanf("%d",&qty);
printf("\nENTER RATE: ");
scanf("%d",&rate);
if (qty>100)
disc=qty*rate*10/100;
net=(qty*rate)-disc;
printf("\nNET AMOUNT: %0.2f",net);
getch();
}
No comments:
Post a Comment