<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>find largest number in array java - Wikitechy</title>
	<atom:link href="https://www.wikitechy.com/interview-questions/tag/find-largest-number-in-array-java/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.wikitechy.com/interview-questions/tag/find-largest-number-in-array-java/</link>
	<description>Interview Questions</description>
	<lastBuildDate>Tue, 14 Sep 2021 05:26:21 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://www.wikitechy.com/interview-questions/wp-content/uploads/2025/10/cropped-wikitechy-icon-32x32.png</url>
	<title>find largest number in array java - Wikitechy</title>
	<link>https://www.wikitechy.com/interview-questions/tag/find-largest-number-in-array-java/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Java program to find second largest number in an array ?</title>
		<link>https://www.wikitechy.com/interview-questions/java/java-program-to-find-second-largest-number-in-an-array/</link>
					<comments>https://www.wikitechy.com/interview-questions/java/java-program-to-find-second-largest-number-in-an-array/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Wed, 14 Jul 2021 00:03:30 +0000</pubDate>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Accenture interview questions and answers]]></category>
		<category><![CDATA[Applied Materials interview questions and answers]]></category>
		<category><![CDATA[Atos interview questions and answers]]></category>
		<category><![CDATA[Capgemini interview questions and answers]]></category>
		<category><![CDATA[CASTING NETWORKS INDIA PVT LIMITED interview questions and answers]]></category>
		<category><![CDATA[CGI Group Inc interview questions and answers]]></category>
		<category><![CDATA[Chetu interview questions and answers]]></category>
		<category><![CDATA[Ciena Corporation interview questions and answers]]></category>
		<category><![CDATA[Collabera Technologies interview questions and answers]]></category>
		<category><![CDATA[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[find largest and smallest number in an array in java]]></category>
		<category><![CDATA[find largest number in array in java]]></category>
		<category><![CDATA[find largest number in array java]]></category>
		<category><![CDATA[find largest number in java]]></category>
		<category><![CDATA[find second largest number in array in java0]]></category>
		<category><![CDATA[find the largest number in an array in java]]></category>
		<category><![CDATA[find the largest number in an array javascript]]></category>
		<category><![CDATA[FIS Global Business Solutions India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Flipkart interview questions and answers]]></category>
		<category><![CDATA[how to find largest and smallest number in java]]></category>
		<category><![CDATA[IBM interview questions and answers]]></category>
		<category><![CDATA[Indecomm Global Services interview questions and answers]]></category>
		<category><![CDATA[Infosys Technologies interview questions and answers]]></category>
		<category><![CDATA[java code to find second largest number in an array]]></category>
		<category><![CDATA[java find largest number in list]]></category>
		<category><![CDATA[java largest int]]></category>
		<category><![CDATA[java program for largest of three numbers]]></category>
		<category><![CDATA[java program to find largest of three numbers]]></category>
		<category><![CDATA[java program to find largest of two numbers]]></category>
		<category><![CDATA[java program to find second largest number in an array]]></category>
		<category><![CDATA[java program to find second largest number of array]]></category>
		<category><![CDATA[java program to find the largest number in an array]]></category>
		<category><![CDATA[L&T Infotech interview questions and answers]]></category>
		<category><![CDATA[largest and smallest java program]]></category>
		<category><![CDATA[largest number in java]]></category>
		<category><![CDATA[largest of 3 numbers in java]]></category>
		<category><![CDATA[largest of 4 numbers using conditional operator in java]]></category>
		<category><![CDATA[MagicBricks Interview Questions and Answers]]></category>
		<category><![CDATA[Mphasis interview questions and answers]]></category>
		<category><![CDATA[NetApp interview questions and answers]]></category>
		<category><![CDATA[Oracle Corporation interview questions and answers]]></category>
		<category><![CDATA[PeopleStrong interview questions and answers]]></category>
		<category><![CDATA[Persistent Systems interview questions and answers]]></category>
		<category><![CDATA[RBS India De interview questions and answers]]></category>
		<category><![CDATA[Reliance Industries Ltd interview questions and answers]]></category>
		<category><![CDATA[SAP Labs India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Tech Mahindra interview questions and answers]]></category>
		<category><![CDATA[UnitedHealth Group interview questions and answers]]></category>
		<category><![CDATA[Virtusa Consulting Services Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Wells Fargo interview questions and answers]]></category>
		<category><![CDATA[Wipro Infotech interview questions and answers]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=668</guid>

					<description><![CDATA[Answer : Given an array of integers, our task is to write a program...]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="java-program-to-find-second-largest-number-in-an-array" class="color-pink" style="text-align: justify;">Java program to find second largest number in an array ?</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Given an <a href="https://www.wikitechy.com/technology/find-closest-pair-two-sorted-arrays/" target="_blank" rel="noopener">array</a> of integers, our task is to write a program that efficiently finds the second <a href="https://www.wikitechy.com/technology/c-programming-kth-smallestlargest-element-unsorted-array-expected-linear-time-2/" target="_blank" rel="noopener">largest element</a> present in the array.</li>
</ul>
</div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="algorithm" class="color-red">Algorithm:</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Initialize two variables first and second to INT_MIN as,
<ul>
<li>first = second = INT_MIN</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li style="list-style-type: none;">
<ul>
<li>Start <a href="https://www.wikitechy.com/technology/c-programming-tree-traversals-inorder-preorder-postorder/" target="_blank" rel="noopener">traversing the array</a>,</li>
</ul>
</li>
</ul>
<p>a) If the current element in array say arr[i] is greater than first. Then update first and second as,</p>
<ul>
<li style="list-style-type: none;">
<ul>
<li>second = first</li>
<li>first = arr[i]</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>b) If the current element is in between first and second, then update second to store the value of current variable as</p>
<li style="list-style-type: none;">
<ul>
<li>second = arr[i]</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Return the value stored in second.</li>
</ul>
</div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="step-1" class="color-blue">step 1</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Iterate the given array.</li>
</ul>
</div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="step-2-first-if-condition-arri-largest" class="color-blue">Step 2 (first if condition arr[i] &gt; largest):</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>If current array value is greater than largest value then move the largest value to <a href="https://www.wikitechy.com/interview-questions/data-structure/how-to-find-second-largest-element-in-bst/" target="_blank" rel="noopener">secondLargest</a> and make current value as largest</li>
</ul>
</div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="step-3-second-if-condition-arri-secondlargest" class="color-blue">Step 3 (second if condition arr[i] &gt;secondLargest )</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>If the current value is smaller than largest and greater than secondLargest then the current value becomes secondLargest.</li>
</ul>
</div>
</div>
<div class="TextHeading">
<div class="hddn">
<h2 id="sample-code-in-java" class="color-red" style="text-align: justify;">Sample code in Java</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-java code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-java code-embed-code">public class SecondLargest {<br/>     <br/>    	public static void main(String[] args) {<br/>     <br/>    		int arr[] = { 24, 56, 57, 105, 102, 62, 58, 46, 76, 95 };<br/>    		int largest = arr[0];<br/>    		int secondLargest = arr[0];<br/>    		<br/>    		System.out.println(&quot;The given array is:&quot; );<br/>    		for (int i = 0; i &lt; arr.length; i++) {<br/>    			System.out.print(arr[i]+&quot;\t&quot;);<br/>    		}<br/>    		for (int i = 0; i &lt; arr.length; i++) {<br/>     <br/>    			if (arr[i] &gt; largest) {<br/>    				secondLargest = largest;<br/>    				largest = arr[i];<br/>     <br/>    			} else if (arr[i] &gt; secondLargest) {<br/>    				secondLargest = arr[i];<br/>     <br/>    			}<br/>    		}<br/>     <br/>    		System.out.println(&quot;\nSecond largest number is:&quot; + secondLargest);<br/>     <br/>    	}<br/>    }</code></pre> </div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="output" class="color-red">Output</h2>
</div>
</div>
<div class="Output">
<div class="hddn">
<figure class="highlight" style="text-align: justify;">
<pre><code class="hljs css" data-lang=""><span class="nt"><span class="hljs-tag">The</span> <span class="hljs-tag">given</span> <span class="hljs-tag">array</span> <span class="hljs-tag">is</span>:
24	56	57	105	 102  62  58  46  76  95	
<span class="hljs-tag">Second</span> <span class="hljs-tag">largest</span> <span class="hljs-tag">number</span> <span class="hljs-tag">is</span><span class="hljs-pseudo">:102</span></span></code></pre>
</figure>
</div>
</div>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/java/java-program-to-find-second-largest-number-in-an-array/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>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 ?</title>
		<link>https://www.wikitechy.com/interview-questions/cpp/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/</link>
					<comments>https://www.wikitechy.com/interview-questions/cpp/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/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Mon, 12 Jul 2021 22:02:37 +0000</pubDate>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[2d array c++]]></category>
		<category><![CDATA[Accenture interview questions and answers]]></category>
		<category><![CDATA[algorithm to find largest number in an array]]></category>
		<category><![CDATA[Applied Materials interview questions and answers]]></category>
		<category><![CDATA[array find]]></category>
		<category><![CDATA[array in c]]></category>
		<category><![CDATA[array in c programming]]></category>
		<category><![CDATA[array programs in java]]></category>
		<category><![CDATA[Atos interview questions and answers]]></category>
		<category><![CDATA[BMC Software interview questions and answers]]></category>
		<category><![CDATA[Bosch India Software interview questions and answers]]></category>
		<category><![CDATA[c interview questions]]></category>
		<category><![CDATA[c program to find largest number in an array]]></category>
		<category><![CDATA[c program to find largest number in an array using function]]></category>
		<category><![CDATA[c program to find largest of n numbers]]></category>
		<category><![CDATA[c++ array class]]></category>
		<category><![CDATA[c++ array functions]]></category>
		<category><![CDATA[c++ program to find largest and second largest number in an array]]></category>
		<category><![CDATA[c++ program to find largest and smallest number in an array]]></category>
		<category><![CDATA[c++ program to find largest of n numbersdynamic array c++]]></category>
		<category><![CDATA[CASTING NETWORKS INDIA PVT LIMITED interview questions and answers]]></category>
		<category><![CDATA[Chetu interview questions and answers]]></category>
		<category><![CDATA[Ciena Corporation interview questions and answers]]></category>
		<category><![CDATA[cpp interview questions]]></category>
		<category><![CDATA[cpp interview questions and answers]]></category>
		<category><![CDATA[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[eInfochips interview questions and answers]]></category>
		<category><![CDATA[Electronics Arts Inc interview questions and answers]]></category>
		<category><![CDATA[find largest number in an array]]></category>
		<category><![CDATA[find largest number in array]]></category>
		<category><![CDATA[find largest number in array c++]]></category>
		<category><![CDATA[find largest number in array in java]]></category>
		<category><![CDATA[find largest number in array java]]></category>
		<category><![CDATA[find largest number in array javascript]]></category>
		<category><![CDATA[find largest number in java]]></category>
		<category><![CDATA[find second largest number in array in java]]></category>
		<category><![CDATA[find smallest number in array c++]]></category>
		<category><![CDATA[Flipkart interview questions and answers]]></category>
		<category><![CDATA[Harman International interview questions and answers]]></category>
		<category><![CDATA[Indecomm Global Services interview questions and answers]]></category>
		<category><![CDATA[java find largest number in list]]></category>
		<category><![CDATA[largest number formed from an array in clength of array c++]]></category>
		<category><![CDATA[Larsen & Toubro interview questions and answers]]></category>
		<category><![CDATA[Mathworks India Private Limited interview questions and answers]]></category>
		<category><![CDATA[Mavenir interview questions and answers]]></category>
		<category><![CDATA[Mphasis interview questions and answers]]></category>
		<category><![CDATA[NetApp interview questions and answers]]></category>
		<category><![CDATA[Oracle Corporation interview questions and answers]]></category>
		<category><![CDATA[PeopleStrong interview questions and answers]]></category>
		<category><![CDATA[Philips Software Centre Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[program to find largest number in an array]]></category>
		<category><![CDATA[return array c++string array c++]]></category>
		<category><![CDATA[SRM Technologies interview questions and answers]]></category>
		<category><![CDATA[Symphony Teleca interview questions and answers]]></category>
		<category><![CDATA[Tech Mahindra interview questions and answers]]></category>
		<category><![CDATA[Tecnotree interview questions and answers]]></category>
		<category><![CDATA[two dimensional array in c++ example]]></category>
		<category><![CDATA[Wipro Infotech interview questions and answers]]></category>
		<category><![CDATA[Wipro interview questions and answers]]></category>
		<category><![CDATA[Yash Technologies interview questions and answers]]></category>
		<category><![CDATA[zycus infotech interview questions and answers]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=358</guid>

					<description><![CDATA[Answer : #include<iostream>...]]></description>
										<content:encoded><![CDATA[<h4 id="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" class="color-pink" style="text-align: justify;">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 ?</h4>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code">#include&lt;iostream&gt;<br/>using namespace std;<br/><br/>int main()<br/>{<br/>int name[5],big,i;<br/><br/>for(i=0; i&lt;=4; i++) {<br/>cout &lt;&lt; &quot;Enter a value&quot; &lt;&lt; i &lt;&lt; &quot;:&quot;;<br/>cin &gt;&gt; name[i];<br/>}<br/>cout &lt;&lt; &quot;name contains:&quot;;<br/>for(i=0; i&lt;=4; i++) {<br/>cout &lt;&lt; name[i]&lt;&lt; &quot;\n&quot;;<br/>}<br/><br/>big = name[0];<br/>for(i = 0; i &lt;= 4; i++) {<br/>if(name[i] &gt; big)<br/>big = name[i];<br/>}<br/><br/>cout &lt;&lt; &quot;The Bigest Number::&quot; &lt;&lt; big &lt;&lt; endl;<br/><br/>return 0;<br/>}</code></pre> </div>
<p style="text-align: justify;">
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/cpp/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/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
