CLASS 10TH PROGRAMS
Program 1: Check Whether a Number is Positive or Negative
#include <stdio.h>
int main()
{
int num;
printf("Enter a number: ");
scanf("%d", &num);
if (num > = 0)
printf("The number is Positive");
else
printf("The number is Negative");
return 0;
}
Program 2: Find the Greater Number Between Two Numbers
#include <stdio.h>
int main() {
int a, b;
printf("Enter two numbers: ");
scanf("%d %d", &a, &b);
if (a > b)
printf("%d is greater", a);
else
printf("%d is greater", b);
return 0;
}
Program 3: Check Whether a Number is Even or Odd
#include <stdio.h>
int main()
{
int num;
printf("Enter a number: ");
scanf("%d", &num);
if (num % 2 == 0)
printf("The number is Even");
else
printf("The number is Odd");
return 0;
}
[GHSS BHOWANA] Page 1 of 2
CLASS 10TH PROGRAMS
Program 4: Check Pass or Fail (Marks > 50 = Pass)
#include <stdio.h>
int main() {
int marks;
printf("Enter marks: ");
scanf("%d", &marks);
if (marks > = 50)
printf("Pass");
else
printf("Fail");
return 0;
}
Program 5: Check Whether a Number is Digit or Not (Using if-else)
#include <stdio.h>
int main() {
char ch;
printf("Enter a Character: ");
scanf("%c", &ch);
if (ch > = 0 && ch < = 9)
printf("It is a Digit");
else
printf("It is Not a Digit");
return 0;
}
Program 6: Check Whether Two Numbers are Same or Different
#include <stdio.h>
int main()
{
int num1, num2;
printf("Enter first number: ");
scanf("%d", &num1);
printf("Enter Second number: ");
scanf("%d", &num2);
if (num1 = = num2)
printf("Both numbers are Same");
else
printf("Both numbers are Different");
return 0;
}
[GHSS BHOWANA] Page 2 of 2