If cost price and selling price of an item is input through the keyboard, write a program to determine whether the seller has made profit or incurred loss. Also determine how much profit he made or loss he incurred

 

Chapter: Decision Control Structure

/* C (a)If cost price and selling price of an item is input through 
the keyboard, write a program to determine whether the seller 
has made profit or incurred loss. Also determine how much 
profit he made or loss he incurred.*/


#include <stdio.h>  //header file
#include <conio.h>   //header file
int main()          //main function.. starting of c code
{
    int cp,sp,check;
    printf("enter cost price: ");
    scanf("%d",&cp);
    printf("\nenter selling price:");
    scanf("%d",&sp);
    check=sp-cp;
    if(check>0)
    {
               printf("\nSeller have profit");
               printf("\nHe got %d profit",check);
    
    }
    else if(check<0)
    {
         check=cp-sp;
         printf("\nSeller have Loss");
         printf("\nHe got %d loss",check);
     }
     else
     printf("You have neither loss nor profit");
     
    getch(); //for holding screen till any key is pressed
    return 0;   //int main() is function so value must be return..
                //u will read in function chapter
}

 


Tag:  If cost price and selling price of an item is input through  the keyboard, write a program to determine whether the seller  has made profit or incurred loss. Also determine how much  profit he made or loss he incurred

Comments

Popular posts from this blog

Puppetting on string | Let us C solution with details description and tutorials | yashwant kanetkar

Article on Septic tank