answersLogoWhite

0

#include<stdio.h>

main()

{

int a[50],max,min,n;

printf("enter the noof digits\n");

scanf("%d",&n);

printf("\nenter the numbers");

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

{

scanf("%d",&a[i]);

}

max=a[0];

min=a[0];

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

{

if(max<a[i])

max=a[i];

if(min>a[i])

min=a[i];

}

printf("\n max is %d \n min is %d",max ,min);

}

User Avatar

Wiki User

15y ago

What else can I help you with?

Continue Learning about Engineering

Write a c program to find the sum of numbers between given limits?

int sum (int min, int max) {return (max-min+1)*(max+min)/2;}


Can you write a source code to find the sum and the largest number of a given array?

In Java, assuming you already created an array of int's, called myArray:int max = myArray[0];int sum = 0;for (int i = 0; i < myArray.length; i++){sum += myArray[i];if (myArray[i] > max)sum = myArray[i]}


How do you Write a java program to find the average of given numbers?

import java.util.Scanner; public class Numbers { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int max = -100; int min = 100; int sum = 0; System.out.println("Enter ten integers"); for(int i = 0; i &lt; 10; i++) { int input = scan.nextInt(); if(input &gt; max)//test if the number entered is larger than any previous number max = input; if(input &lt; min)//test if the number entered is smaller than any previous number min = input; sum += input;//add the input to the sum } System.out.println("The maximum number entered is: " + max + "\nThe minimum number entered is: " + min + "\nThe average of the numbers is: " + (sum / 10));//prints out the results } }


What is the least possible number of iterations for a for loop?

The least possible is no iterations: for (x=0; x&lt;max; ++x) { // ... } In the above example, if max is less than or equal to zero then the body of the loop will not execute.


What is the code for a C program to find the largest and smallest number?

Fist of all, let's assume that by "list" you mean "array." Otherwise we would need your list implementation in order to be able to iterate through the elements. int[] nums; // assume these are the numbers you want to search through int nums_length; // also assume that we know how many numbers are in nums int min; // smallest number in nums int max; // largest number in nums // special case for an empty list of numbers: set min = max = 0 if(nums_length == 0) { min = 0; max = 0; }else { // start min and max off as equal to the first number min = nums[0]; max = nums[0]; // iterate through nums int i; for(i = 1; i &lt; nums_length; ++i) { // update max, if necessary if( nums[i] &gt; max ) { max = nums[i]; } // update min, if necessary if(nums[i] &lt; min) { min = nums[i]; } } } // min and max are now properly set (or both equal to 0 if nums is empty)

Related Questions

Find large number in the given two numbers?

int max = a&gt;b?a:b; // set max to the larger of a and b


Write a java programm to find maximum number in the given array?

class maximum{public static void main(string...args){System.out.println(max(new int[]{5,3,6,2,4,61}));}static int max(int[]a){int max=0;for(int i=0;imax)max=a[i];}return max;}}


What is the largest number of babies any single woman has ever given birth to?

The max that someone can have is 50. I think the max anyone has ever had is 19


C program to find out largest and smallest in a list of given numbers using arrays?

#include &lt;iostream&gt; using std::cout; using std::cin; using std::endl; int main() { int max; int num; for (int counter = 0; counter&lt;15; counter++) { cout &lt;&lt;"Enter a number: "; cin &gt;&gt; max; cout &lt;&lt; "Enter another number: "; cin &gt;&gt; num; if (num &gt; max) num = max; cout &lt;&lt; "The largest number is " &lt;&lt;max; } return 0; }


Write a c program to find the sum of numbers between given limits?

int sum (int min, int max) {return (max-min+1)*(max+min)/2;}


How do you pronouce Max in the Samoan language?

Max is pronounced "maka" or "masa"


Can you write a source code to find the sum and the largest number of a given array?

In Java, assuming you already created an array of int's, called myArray:int max = myArray[0];int sum = 0;for (int i = 0; i < myArray.length; i++){sum += myArray[i];if (myArray[i] > max)sum = myArray[i]}


A c program to find maximum number in a 3 by 3 matrix?

int matrix[][]; // the matrix to find the max in int max = matrix[0][0]; int r,c; for(r = 0; r &lt; 3; ++r) { for(c = 0; c &lt; 3; ++c) { if(matrix[r][c] &gt; max) { max = matrix[r][c]; } } } // max is now the maximum number in matrix


The MIN function is used to determine the highest number in a range.?

MIN is used to find the lowest number in a range. You would use MAX or LARGE to find the highest number in a range.


What has the author Max H Miller written?

Max H. Miller has written: 'The logic of language development in early childhood' -- subject(s): Language acquisition, Language and logic, Semantics


How do you find number 197 in Pokemon platinum?

Number 197, Umbreon, is found by evolving an Eevee with max happiness during the night.


How do you find max value out of anonymous array in java?

java is very most important language in computer field. .net is also useful