Answers for "How to find maximum of number code in c++"

C++
2

c++ how to get maximum value

x = 1, y  = 2;
fmax(x , y);
//if you want to print it right away:
cout << fmax(x , y);
//if you want to store it:
int j = fmax(x, y);
cout << j;

//output 2
Posted by: Guest on April-06-2021
0

maximum out of 4 numbers c++ code

Source Code:

#include<stdio.h>
#include<conio.h>
void main()
{
	int a,b,c,d;
	clrscr();
	printf("Enter the value of a:");
	scanf("%d",&a);
	printf("Enter the value of b:");
	scanf("%d",&b);
	printf("Enter the value of c:");
	scanf("%d",&c);
	printf("Enter the value of d:");
	scanf("%d",&d);

	if(a>b)
	{
		if(a>c)
		{
			if(a>d)
			{
				printf("a is maximum”);
			}
			else
			{
				printf("d is maximum");
			}
		}
		else
		{
			if(c>d)
			{
				printf("c is maximum ");
			}
			else
			{
				printf("d is maximum ");
			}
		}
	}
	else
	{
		if(b>c)
		{
			if(b>d)
			{
				printf("b is maximum");
			}
			else
			{
				printf("d is maximum");
			}
		}

		else
		{
			if(c>d)
			{
				printf("c is maximum ");
			}
			else
			{
				printf("d is maximum ");
			}
		}
	}
	getch();
}

Output:

Enter the value of a: 10
Enter the value of b: 20
Enter the value of c: 30
Enter the value of d: 40

D is maximum.

Enter the value of a: 40
Enter the value of b: 30
Enter the value of c: 20
Enter the value of d: 10

A is maximum.
Posted by: Guest on June-07-2021

Code answers related to "How to find maximum of number code in c++"

Browse Popular Code Answers by Language