Write a function that takes an integer array as an input and find the largest number in the array. You cannot sort array or use any API or searching needs ?

Answer : #include…

Write a function that takes an integer array as an input and find the largest number in the array. You cannot sort array or use any API or searching needs ?

[pastacode lang=”cpp” manual=”%23include%3Ciostream%3E%0Ausing%20namespace%20std%3B%0A%0Aint%20main()%0A%7B%0Aint%20name%5B5%5D%2Cbig%2Ci%3B%0A%0Afor(i%3D0%3B%20i%3C%3D4%3B%20i%2B%2B)%20%7B%0Acout%20%3C%3C%20%22Enter%20a%20value%22%20%3C%3C%20i%20%3C%3C%20%22%3A%22%3B%0Acin%20%3E%3E%20name%5Bi%5D%3B%0A%7D%0Acout%20%3C%3C%20%22name%20contains%3A%22%3B%0Afor(i%3D0%3B%20i%3C%3D4%3B%20i%2B%2B)%20%7B%0Acout%20%3C%3C%20name%5Bi%5D%3C%3C%20%22%5Cn%22%3B%0A%7D%0A%0Abig%20%3D%20name%5B0%5D%3B%0Afor(i%20%3D%200%3B%20i%20%3C%3D%204%3B%20i%2B%2B)%20%7B%0Aif(name%5Bi%5D%20%3E%20big)%0Abig%20%3D%20name%5Bi%5D%3B%0A%7D%0A%0Acout%20%3C%3C%20%22The%20Bigest%20Number%3A%3A%22%20%3C%3C%20big%20%3C%3C%20endl%3B%0A%0Areturn%200%3B%0A%7D” message=”” highlight=”” provider=”manual”/]

Leave a Reply

Your email address will not be published. Required fields are marked *