answersLogoWhite

0

#include<stdio.h>

main()

{

int n,m,i,max;

printf("How many numbers(n) you going to enter:");

scanf("%d",&n);

printf("Enter the numbers:");

scanf("%d",&m);

max=m;

for(i=2;i<=n;i++)

{

scanf("%d",&m);

if(m>max)

max=m;

}

printf("The Largest Number is %d",max);

}

Here is a code with explanation and dry run hope it can be helpful

http://fahad-cprogramming.blogspot.com/2014/04/find-maximum-and-minimum-number-in.html

User Avatar

Wiki User

11y ago

What else can I help you with?

Continue Learning about Engineering

Biggest of three numbers using ternary operator in java?

// largest = largest of a, b, c public class largest { public static void main(String args[]) { int a,b,c,largest; a=0; b=0; c=0; a=Integer.parseInt(args[0]); b=Integer.parseInt(args[1]); c=Integer.parseInt(args[2]); largest=a&gt;b?(a&gt;c?a:c):(b&gt;c?b:c); System.out.println("The largest no. of "+a+","+b+"and"+c+"is"+largest); } }


How do you write a program to find out largest number between two numbers using ternary operators?

// assume you want the find the largest of ints a,b,c: int max = (a&gt;b&amp;&amp;a&gt;c?a:b&gt;c?b:c);


C program to find the second highest number from a set of numbers?

main() { in a,b,c,d; printf("\n enter any four numbers"); scanf("%d%d%d%d",&amp;a,&amp;b,&amp;c,&amp;d); if(a==ba==cb==cb==dc==d) printf("\n numbers must be different"); else { if(a&gt;b&amp;&amp;a&gt;c&amp;&amp;a&gt;b) X=b&gt;c&amp;&amp;b&gt;d?b;c&gt;d?c:d; else if(b&gt;c&amp;&amp;b&gt;d) x=a&gt;c&amp;&amp;a&gt;b?a:c&lt;d?c:d; else if(c&gt;d) x=a&gt;b&amp;&amp;a&gt;d?a:b&gt;d?b:d; else x=a&gt;b&amp;&amp;a&gt;c?a:b&gt;c?b:c; printf("\n %d is second max vaalue",x); { }


Write a c plus plus program to find the largest and second largest number from an array?

#include &lt;iostream.h&gt; #include &lt;conio.h&gt; class largest { public: int a[10],i,b,s; void get(); }; void largest :: get() { cout&lt;&lt;"Enter the numbers"&lt;&lt;endl; for(i=0;i&lt;10;i++) { cin&gt;&gt;a[i]; } b=0; for(i=0;i&lt;10;i++) { if(b&gt;=a[i]) b=b; else b=a[i]; } cout&lt;&lt;"Largest No-"&lt;&lt;b&lt;&lt;endl; s=0; for(i=0;i&lt;10;i++) { if((s&gt;=a[i])&amp;&amp;(s!=b)) s=s; else s=a[i]; } cout&lt;&lt;"Second Largest No-"&lt;&lt;s&lt;&lt;endl; } void main() { clrscr(); largest l; l.get(); getch(); }


How do you print non-prime numbers in java?

Loop through some numbers - for example, 2 through 100 - and check each one whether it is a prime number (write a second loop to test whether it is divisible by any number between 2 and the number minus 1). If, in this second loop, you find a factor that is greater than 1 and less than the number, it is not a prime, and you can print it out.

Related Questions

Write an algorithm to read two numbers then display the largest?

Read 2 numbers. If first is larger than second, display second, else display first. That's for the smallest. For the largest reverse the two. For each of the other two, it's easier to just create a variable, call it largest. Initialize it to a very small number, say -1. As you read each number, compare it to largest. If the number is larger than largest, set largest equal to the number. When you finish each list of numbers, then print largest. Best answer Read 2 numbers. If first is larger than second, display second, else display first. That's for the smallest. For the largest reverse the two. For each of the other two, it's easier to just create a variable, call it largest. Initialize it to a very small number, say -1. As you read each number, compare it to largest. If the number is larger than largest, set largest equal to the number. When you finish each list of numbers, then print largest.


What is the condition of second largest number?

There is no such condition. The algorithm to locate the second largest number in an array of numbers is: Sort the array in descending order. Remove the duplicate values from the array. If there are two or more elements remaining, return the second number. If there is less than two elements remaining, return the NaN value (not a number).


How do you i get the median?

You put all the numbers in order(smallest to largest) then cross off the first the last then the second then the second to last and so on the middle number is the median.


If the sum of three numbers is 99 and the first number is 10 greater than the second and 20 greater than the third. find the largest of the three numbers.?

43


Write an algorithm to find the largest number amongst three numbers and draw a flowchart?

Step1- Read a,b,c. Step2-if a&gt;b continue step 5. Step3- b&gt;c then print “b is the largest &quot; and continue step 7. Step4- continue step 6 Step5-if a&gt;c then print “a is the largest &quot; then continue step7. Step6- print “z is largest&quot;. Step7- end.


Biggest of three numbers using ternary operator in java?

// largest = largest of a, b, c public class largest { public static void main(String args[]) { int a,b,c,largest; a=0; b=0; c=0; a=Integer.parseInt(args[0]); b=Integer.parseInt(args[1]); c=Integer.parseInt(args[2]); largest=a&gt;b?(a&gt;c?a:c):(b&gt;c?b:c); System.out.println("The largest no. of "+a+","+b+"and"+c+"is"+largest); } }


What is the second largest numeral using 3 numbers?

998.


Does islam have the second largest number of followers in the world?

Yes, Islam religion followers are the second largest number of followers after Christianity.


The sum of two numbers is -42 the first number minus the second number is 52 Find the numbers?

= The sum of two numbers is -42 the first number minus the second number is 52 Find the numbers? =


How do you find the LCM of 2 numbers if one number is prime?

If the second number is a multiple of the prime number, than the LCM is the second number. If the second number is not a multiple of the prime number, then the two numbers are relatively prime, and the LCM is the product of the two numbers.


What is the second largest number called?

thousand


Which borough is the largest in the area and second largest in population?

Brooklyn has the highest population in numbers, but Manhattan is the most densely populated borough.