0% found this document useful (0 votes)
3 views2 pages

All Programsf

The document contains a series of C programming exercises that demonstrate basic programming concepts such as checking if a number is even or odd, determining if a number is positive or negative, identifying leap years, and comparing numbers. Each exercise includes a brief description and corresponding code snippets. The programs cover fundamental conditional statements and user input handling.

Uploaded by

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

All Programsf

The document contains a series of C programming exercises that demonstrate basic programming concepts such as checking if a number is even or odd, determining if a number is positive or negative, identifying leap years, and comparing numbers. Each exercise includes a brief description and corresponding code snippets. The programs cover fundamental conditional statements and user input handling.

Uploaded by

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

ALL PROGRAMS

1. Write a that show a 2. Write a program that show


number whether even or a number is positive or
odd. negative.
#include<stdio.h> #include<stdio.h>
void main(){ void main(){
int num; int num;
printf("Enter the printf("Enter the Number:
number: "); ");
scanf("%d",&num); scanf("%d",&num);
if(num % 2 == 0) if(num < 0)
printf("Number is printf("The number is
even."); negative.");
else else{
printf("Number is if(num == 0)
odd."); printf("THe number is
} not positive or negative.");
else
printf("The number is
Postive."); }
}
3. Write a program that shows 4. Write a program that shows
a year is leap or not. inut is digit or not digit.
#include<stdio.h> #include<stdio.h>
void main(){ void main(){
int year; char dig;
printf("Enter the year: printf("Enter The digit:
"); ");
scanf("%d",&year); scanf("%c",&dig);

if(year%4==0){ if(dig >= 0 && dig <= 9)


printf("This is printf("DIgit");
leap year"); else
} printf("not
else{ Digit");
printf("Not leap }
Yaer");
}
}
5. Write a program that 6. Write a program that shows
show that number is numbers are equa or not.
greater or less than. #include<stdio.h>
#include<stdio.h> void main(){
void main(){ int a,b;
int a,b; printf("Enter the Value of
printf("Enter the a: ");
Value of a: "); scanf("%d",&a);
scanf("%d",&a); printf("Enter the Value of
printf("Enter the b: ");
Value of b: "); scanf("%d",&b);
scanf("%d",&b); if(a == b)
if(a > b) printf("Number are
printf("a is equal.");
grater than b."); else
else printf("Nuumber
printf("a is less are not equal.");
than b."); }
}

7. Write a program that 8. Write a program that take


take mark and show fail percentage and show fail or
or pass. pass.
#include<stdio.h> #include<stdio.h>
void main(){ void main(){
int marks; int percentage;
printf("Enter the printf("Enter the
Marks: "); Percentage: ");
scanf("%d",&marks) scanf("%d",&percentage)
; ;
if(marks > 40) if(percentage > 40)
printf("Pass"); printf("Pass");
else else
printf("Fail"); printf("Fail");
} }

You might also like