You are here:   HomeC Programming (Theory)Basic Of C Prog.
by Dinesh Thakur Category: Basic Of C Programming



#include <stdio.h>

void main()
const int level1 = 30;
const int level2 = 50;
const double discount1 = 0.10;
const double discount2 = 0.15;
const double unit_price = 3.50;
int q1 = 0;
int q2 = 0;
int qty_over_level1 = 0;
int qty_over_level2 = 0;
printf("Quantity?: “);
scanf("%d", &q1);
q2 = q 1;
qty_oveclevel2 = q1%leveI2;
q1 -= qty_over_level2;
qty_over_level1 = q1 %level1;
q1 -= qty_over_level1;
printf("\n The total price for %d is $%.21£\n", q2,uniCprice*(q1 +(1.0- discount1 )* qty_over_level1 +( 1.0-discount2)* qty_over_level2));
Quantity? 45
The total price for 45 is $133.88

Subscribe To Free Daily Newsletter!

Get Free News Updates Delivered Directly To Your Inbox
About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to contact us.

What's New and Popular

Popular Article