0% found this document useful (0 votes)
19 views3 pages

Let Us C: 2: Attempt The Following

This document provides 3 C programs to solve different problems. The first program determines if a seller made a profit or loss based on cost and selling price input. The second program checks if a number is even or odd. The third program checks if a year is a leap year or not.

Uploaded by

venkateshgavini
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views3 pages

Let Us C: 2: Attempt The Following

This document provides 3 C programs to solve different problems. The first program determines if a seller made a profit or loss based on cost and selling price input. The second program checks if a number is even or odd. The third program checks if a year is a leap year or not.

Uploaded by

venkateshgavini
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

LET US C:

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>

2.)Any integer is input through the keyboard. Write a program


to find out whether it is an odd number or even number.
int main(void) {
int c;
printf("Enter c:");
scanf("%d",&c);
if(c%2==0)
printf("IT IS EVEN");
else
printf("IT IS ODD");
return 0;
}
3.)Any year is input through the keyboard. Write a
program to determine whether the year is a leap year
or not.
#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;
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy