Program to calculate profit and lose by C-language

Program to calculate profit and lose by C-language

#include<stdio.h>
#include<string.h>
int main()
{
 float sp,cp,profit,loss;
 printf("Enter cost price\n");
 scanf("%f",&cp);
 printf("Enter selling price\n");
 scanf("%f",&sp);
 if(sp>cp)
 {
  profit=sp-cp;
  printf("Profit is %f rupee",profit);
 }
 else
 {
 loss=cp-sp;
  printf("Loss is %f rupee",loss);
 }
 
}
OUTPUT
Enter cost price
55
Enter selling price
78
Profit is 23.000000 rupee

Comments

Post a Comment

Popular posts

Creative pattern of butterfly in C-language

Program to show present time and date in C-language

Introduction of C-language.

Program to cheque enter number is a perfect number or not using if else in C-language

Program to cheque four digits number is palindrome or not in C-language

Program to print the cube of a number in c-language

Simple Hello world program in c- language