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.

how to write program greatest number

+11 votes
asked Sep 8, 2023 by pritesh deore (230 points)

6 Answers

+1 vote
answered Sep 8, 2023 by Shripad Chaudhari (160 points)
#include<stdio.h>

int main()

{

int a,b;

printf("Enter the the two number'';

scanf("%d",&a,&b);

if(a>b)

{

printf("a is greater");

}

else

{

printf("b is greater");

}

return 0;

}
+1 vote
answered Sep 9, 2023 by Tushar gaming (170 points)
#include <stdio.h>

int main()
{
int a, b;
printf("ENTER TWO INTEGER NUMBER\n");
scanf("%d%d", &a, &b) ;
if(a>b)
{
 printf("%d is big\n",a) ;
}
else
{
printf("%d is big\n",b);}
}
0 votes
answered Sep 9, 2023 by Ananya K.J (300 points)
Here is a C++ program to solve the problem of greatest integers among the given input of 4 integers. if needed for particular number can call the big function the input number of times or use a loop . using array for a list of integers to compare largest among them is more suitable

#include <iostream>

using namespace std;
int big(int x,int y)
{
   return(x>y)?x:y;
}

int main()
{
   int a,b,c,d,s;
   cin>>a>>b>>c>>d;
   s=big(big(big(a,b),c),d);
   cout<<s;

    return 0;
}
+1 vote
answered Sep 15, 2023 by Gulshan Negi (1,580 points)

Well, here is the simple C++ program to find the largest number.

#include <iostream>
using namespace std;

int main() {
    int num1, num2, num3;

    // Input three numbers from the user
    cout << "Enter three numbers: ";
    cin >> num1 >> num2 >> num3;

    // Compare the numbers to find the greatest one
    if (num1 >= num2 && num1 >= num3) {
        cout << "The greatest number is: " << num1 << endl;
    } else if (num2 >= num1 && num2 >= num3) {
        cout << "The greatest number is: " << num2 << endl;
    } else {
        cout << "The greatest number is: " << num3 << endl;
    }

    return 0;
}

Thanks

0 votes
answered Sep 15, 2023 by Krutik Patel (140 points)
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
void main()
{
    clrscr();
    int a,b,c,d,x,y;
    printf("Enter first value : ");
    scanf("%d",&a);
    printf("Enter second value: ");
    scanf("%d",&b);
    printf("Enter third value:");
    scanf("%d",&c);
    x=(a+b+abs(a-b))/2;
    y=(x+c+abs(x-c))/2;
    printf("maximum value=%d",y);
    getch();

}
0 votes
answered Oct 1, 2023 by PRINCE KUMAR SINGH ABC 3 (140 points)

#include<stdio.h>

#include<limits.h>

int main() {

int n;

printf("enter how many number you have to compare :");

scanf("%d",&n);

int arr[n];

printf("enter numbers\n");

for(int i=0;i<n;i++){

scanf("%d",&arr[i]);

}

int max= INT_MIN;

for(int i=0;i<n;i++){

if(max<arr[i]) {

max=arr[i]; }

}

printf("\nthe largest is %d",max);

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.
...