Compare two integers in C
Compare two integers in C
Algorithm
Let’s first see what should be the step-by-step procedure to compare two integers−
START Step 1 → Take two integer variables, say A & B Step 2 → Assign values to variables Step 3 → Compare variables if A is greater than B Step 4 → If true print A is greater than B Step 5 → If false print A is not greater than B STOP Let's program
#include <stdio.h> int main() { int a, b; a = 11; b = 99; // to take values from user input uncomment the below lines − // printf("Enter value for A :"); // scanf("%d", &a); // printf("Enter value for B :"); // scanf("%d", &b); if(a > b) printf("a is greater than b"); else printf("a is not greater than b"); return 0; }