Biggest of Two Numbers in C Language

Find The Largest Number Out of Thre...
Find The Largest Number Out of Three in Python (Video 27)

Program to Find Biggest of Two Numbers in C

Hi friends, in this tutorial you will learn how to write a program to find the biggest of two numbers in C language. Also, we can do it in different ways but in this example, we will do it in a simple way.

Also read, Input Output Functions in C Language with Examples

Logic of the program:-

  • Initially, we will declare three integer numbers such as a, b, and c, and another integer variable “big” that stores the biggest number after the execution of the program.
  • ‘a’ is compared with ‘b’. If a is greater than b then a will be considered biggest and stored to the resultant variable ‘big’ otherwise ‘b’ will be considered biggest and stored to the resultant variable big.

Below is an example to find biggest of two numbers in C language

#include <stdio.h>
main(){
  int a, b, big;
  printf("\n Enter the two numbers: ");
  scanf("%d %d",&a, &b);
  if(a>b){
    big = a;
  }
  else{
    big = b;
  }
  printf("\n The biggest of two numbers is: %d",big);
}

After running the above program, the user has to enter two numbers manually and then press the key ENTER. Now the program will be executed and the result is displayed as shown below

Enter the two numbers: 2 3
The biggest of two numbers is: 3
Process returned 0 (0x0) execution time : 4.971 s
Press any key to continue.

Conclusion:- I hope this tutorial will help you to understand the overview. If there is any doubt then please leave a comment below


Leave a Comment