Write a C C++ program to find greater in two numbers

 

Flowchart

Greater in two numbers flowchart

 

Coding in C

#include<stdio.h>
int main()
{
int n1,n2;
printf(“Enter two numbers : “);
scanf(“%d%d”,&n1,&n2);
if(n1>n2)
{
printf(“Greater number = %d”,n1);
}
else
{
printf(“Greater number = %d”,n2);
}
return 0;
}

 

Coding in C++

#include<iostream>
using namespace std;
int main()
{
int n1,n2;
cout<<“Enter two numbers : “;
cin>>n1>>n2;
if(n1>n2)
{
cout<<“Greater number = “<<n1;
}
else
{
cout<<“Greater number = “<<n2;
}
return 0;
}

 

Output

Greater in two numbers output

 

Published by

admin

I am a computer teacher, programmer and web developer