Saturday 7 July 2012

Conditional statement002

Input :- Quantity and price per item.
Output : - Calculate the total expenses where as a discount of  ten percent is offered if the quantity purchased is more than thousand. 

#include <stdio.h>
#include <conio.h>
void main ( )
{      
        int        qty, dis = 0;
        float     rate, tot;
        clrscr ( );
                       
        printf ("\n\n\n\t\t Enter quantity.....:"); scanf ("%d",&qty);
        printf ("\n\n\t\t Enter rate.....:"); scanf ("%f",&rate);
                  
        if ( qty > 1000 )
        {                   
                  dis = 10;
        }
        tot = (qty * rate) - (qty * rate * dis / 100);
                            
        printf ("\n\n\n\t\t Total expenses.......: %.2f",tot);
        getch ( );
}

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...