Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

write a programm to find the greatest of 3 number and also check the largest number is prime or not

0 votes
asked Feb 26, 2020 by Arathy Geetha (120 points)

2 Answers

0 votes
answered Feb 27, 2020 by keshav sharma (140 points)
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{  int greatest;
    int a,b,c;
    int flag=0;
    cout<<"enter a,b,c";
    cin>>a;
    cin>>b;
    cin>>c;
    if(a>b&&a>c)
    {
           greatest=a;
            cout<<greatest;
        
    }
    else if(b>a&&b>c)
    {
        greatest=b;
         cout<<greatest;
    }
    else
    {
        greatest=c;
         cout<<greatest;
    }
    if(greatest==2)
    {
        cout<<"greatest is prime";
    }

    for(int i=3;i<greatest;i++)
    {
        if(greatest%i==0)
        {
            flag=1;
        }
    }
    if(flag==1)
    {
        cout<<" not prime ";
    }
    else
    {
        cout<<" prime ";
    }
    
    return 0;
}
0 votes
answered Feb 28, 2020 by SUMAN OJHA (140 points)
#include<stdio.h>

main()

{

int num1,num2,num3,large;

printf("Enter the  first number:");

scanf("%d",&num1);

printf("Enter the second number:");

scanf("%d",num2);

printf("Enter the third number:");

scanf("%d",num3);

large=num1>num2?((num1>num3)?num1:num3):((num2>num3)?num2:num3);

printf("\n The largest number is :%d",large);

    if(large%2!=0)

printf("\n prime number");

    else

printf("\n non-prime number);

return 0;

}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...