C Program To Find Largest of Two Numbers (Simple Way)
Algorithm -:
Program Start
Declaration of Variables
Input Two number
Check the condition
Display answer according the condition
Program End
Program -:
//C Program To Find Largest of Two Numbers (Simple Way)
#include<stdio.h>
void main()
{
// Variable declaration
int a,b, larg;
printf("Enter Two Numbers\n");
scanf("%d %d",&a,&b);
// larg among a and b
if(a>b)
{
larg = a;
}
else
{
larg = b;
}
//Display Largest number
printf("Largest Number is : %d",larg);
}
Output -:
Enter Two Numbers
39
49
Largest Number is : 45
C Program To Find Largest of Two Numbers Using Function
Algorithm -:
Program Start
Declaration of Variables
Input Two number
Calling Function to find Largest Number
Check the condition
Display answer according the condition
Program End
Program -:
//C Program To Find Largest of Two Numbers Using Function
#include<stdio.h>
void largest(int a, int b)
{
int larg;
if(a>b) // larg among a and b
{
larg = a;
}
else
{
larg = b;
}
//Display Largest number
printf("Largest Number is : %d",larg);
}
void main()
{
// Variable declaration
int a,b;
printf("Enter Two Numbers\n");
scanf("%d %d",&a,&b);
largest(a,b);
}
Output -:
Enter Two Numbers
3
9
Largest Number is : 9
C Program To Find Largest of Two Numbers Using Conditional Operator
Program -:
//C Program To Find Largest of Two Numbers Using Conditional Operator
#include<stdio.h>
void main()
{
// Variable declaration
int a,b,larg;
printf("Enter Two Number\n");
scanf("%d %d",&a,&b);
// Larg among a, b and c
larg = a>b?a:b;
//Display largest number
printf("Largest Number is : %d",larg);
}
C Program To Find Largest of Two Numbers (Simple Way)
Algorithm -:
Program -:
Output -:
C Program To Find Largest of Two Numbers Using Function
Algorithm -:
Program -:
Output -:
C Program To Find Largest of Two Numbers Using Conditional Operator
Program -:
Output -:
need an explanation for this answer? contact us directly to get an explanation for this answer