0
How many ways can we use to find largest number in c++?
The one way is if statement ,if else, nested if,....what else?
7 Réponses
+ 2
Anas kayani that's ok, let me explain with examples.
1) one way is to perform the comparison whenever you inputting the integers and keep track of largest number entered till now.
Here is one exmple using it 👇
https://code.sololearn.com/chc7KBgOb7YZ/?ref=app
2) other way is to sort the array in increasing order and display the last element.
Here is one exmple using it 👇
https://code.sololearn.com/cU3Z4i4SiFlm/?ref=app
There are many other ways of doing it also, but these are the most common one.
+ 1
I cannot understand
+ 1
I think there's infinirely many different ways. Here's one, but i think there are even crazier ones
https://code.sololearn.com/cP1LtPA7WdBz/?ref=app
0
They have done using for loop
0
Maximum ways to find largest of numbers ?
0
Only 2 ways
1) independent comparison { will take liner time O(n) }
2) sorting { time complexity will depend on sorting algorithm used }