Skip to main content

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



Flowchart

Draw a flowchart to find greatest in two numbers

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

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