Pages

Monday, January 2, 2012

C Programming to decide profit and loss along with amount


/*to decide profit or loss along with amount*/
#include<stdio.h>
#include<stdlib.h>
int main( )
{
    float sp,cp,profit,loss;
    printf ("enter sp and cp: ");
    scanf ("%f%f",&sp,&cp);
    if (sp>cp)
    {
        profit=sp-cp;
        printf ("profit=%f",profit);
    }
    else
    {
        loss=cp-sp;
        printf ("loss=%f",loss);
    }
    system ("pause");
    return 0;
}

No comments:

Post a Comment