UncleCoder.com

UncleCoder.com

Free programming examples and instructions

# C program to find largest among two numbers without else.

## C program for how to find largest among two numbers without using 'else'

Posted on 30 Aug 2017 Category: C Views: 512

Edited on 18 Sep 2017

## C program to find largest among two numbers without using 'else'

We know , how to find the largest among two numbers using ‘if-else’ condition. Here is another method to find largest among two numbers without using ‘else’ part.

C program to find largest among two numbers is given as below

``````#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,large;
printf(“enter the first number :”);
scanf(“%d”,&a);
printf(“enter the second number :”);
scanf(“%d”,&b);
large=a;
if(b>a)
{
large=b;
}
printf(“largest number =%d”,large);
getch();
}
``````

steps:-

1. In this program the computer reads input from the user.
2. Then set the value of ‘a’ as ‘large’.
3. Then it checks whether the other number (b) is greater than  large (a), if this condition is true, then value of ‘b’ is set to ‘large’.
4. Final step is to print the variable large, which holds the largest among the two numbers.

• View all

• View all

• View all

• View all

• View all