Let Us C: 2: Attempt The Following
Let Us C: 2: Attempt The Following
2ND CHAPTER:
[C] Attempt the following:
1.)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>
int main(void) {
int cp,sp;
printf("Enter cp and sp:");
scanf("%d%d",&cp,&sp);
int l=cp-sp;
if(l>0)
printf("U had a profit");
else if(l<0)
printf("U had loss");
else
printf("NO loss and no profit");
return 0;
}
#include <stdio.h>
int main(void) {
int y;
printf("Enter the year u want:");
scanf("%d",&y);
if(y%400==0)
printf("Yes it is leap year");
else if(y%4==0 && y%100!=0)
printf("Leap year");
else
printf("not a leap year");
return 0;
}