Biggest of Two Numbers in C Language
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.
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
int a, b, big;
printf("\n Enter the two numbers: ");
scanf("%d %d",&a, &b);
big = a;
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
Originally published at https://pbphpsolutions.com on June 27, 2022.