Pages

Sunday, 26 August 2012

Calculating Grand Total on Discount


#include <stdio.h>
#include <conio.h>

void main()
{
                clrscr();

                int a, b, c, d, e;
                float total, discount, discountAmt, grandTotal;

                printf("Enter the 1st amount : ");
                scanf("%d",&a);

                printf("Enter the 2nd amount : ");
                scanf("%d",&b);

                printf("Enter the 3rd amount : ");
                scanf("%d",&c);

                printf("Enter the 4th amount : ");
                scanf("%d",&d);

                printf("Enter the 5th amount : ");
                scanf("%d",&e);

                total = a+b+c+d+e;

                printf("\n\nTotal = Rs. %.f",total);

                if(total>5000)
                {
                                discount = 5;
                }
                else
                {
                                discount = 3;
                }

                printf("\n\nYou will get %.f discount.",discount);

                discountAmt = ((float) discount/100) * total;

                grandTotal = total - discountAmt;

                printf("\n\nDiscount Amount = Rs. %.f",discountAmt);

                printf("\n\Total Amount =  Rs. %.f",grandTotal);

                getch();
}

0 comments:

Post a Comment