C++ - Write a C++ program to find maximum between two numbers.

C++ - Write a C++ program to find maximum between two numbers.

 

Question:



Write a C++ program to find maximum between two numbers.
 


Answer:


PROGRAM:------

image

image


 

copy code:-

#include<stdio.h> // standard header functions

#include<conio.h>

void main() // main method declaration

{

clrscr(); // clearing the console

int x, y, greatest; // declare the required variables

printf("Enter two number : "); // display the instruction to the user

scanf("%d%d",&x,&y); // get the input for two numbers x and y

if(x>y) // check if x greater than y

{

greatest=x; // if true set the greatest to x

}

else if(y>x) // else check if y greater than x

{

greatest=y; // if true set the greatest to y

}

else // if none is true than both are same numbers

{

printf("The entered numbers are same");

greatest = x;

}

printf("Biggest of the two number is %d",greatest);

getch();

}

output:-------


image
Previous Post
Next Post

post written by:

0 Comments: