C Program to Compare Two Integers

In this c programming example we will learn how to compare two integeres.

Algorithm

 

  1. Take two integers from user by printf() function
  2. These two integer values we will assign to a, b by scanf() function
  3. Now we will compare these two varaibles a,b with if condition
  4. If a is greater than b then if condition will execute and print the result as "a is greate than b"
  5. If we gives small value for a then else condition will executes and print result as "a is not greate than b"

 

 

Simple C example to compare two integers

 

#include <stdio.h>


int main() {
   int a, b;
 printf("Enter number a : ");
    scanf("%d", &a);
 printf("Enter number b : ");
    scanf("%d", &b);

   if(a > b)
      printf("a is greater than b");
   else
      printf("a is not greater than b");

   return 0;
}

 

Output

Enter number a : 10

Enter number b :  3  

a is greater than b

 

BankManagement System Project

Calendar Application for beginner Project

Contact Management System Project

Cricket Score Card C Project CSMS

What Day it is - Simple C Project For Beginners

School Billing Management System project with c

Student Record System project with c