answersLogoWhite

0


Best Answer

#include ; using namespace std; int main () { int number1 = 0; int number2 = 0; int number3 = 0; int number4 = 0; int number5 = 0; coutnumber2>>number3>>number4>>number5; {if (number1 > number2) if (number1 > number3) if (number1 > number4) if (number1 > number5) cout

User Avatar

Wiki User

βˆ™ 15y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

βˆ™ 13y ago

#include <iostream>

#include <cstdlib>

using namespace std;

int generatehighvalue (int trials);

void countoccurrence(int trials);

void main ()

{

int highestgenerated;

highestgenerated = generatehighvalue(1000);

cout <<"difference we got is"<<RAND_MAX - highestgenerated<<endl;

cout<<"hishest possible is"<<RAND_MAX<< "and highest generated is"<<highestgenerated<<endl;

countoccurence(1);

}

]

int generatehighvalue (int valuetrials)

[

int num, compare;

num = rand();

compare = 0;

if (trials > 1)

compare = generatehighvalue(trials - 1)

if (compare > num)

return compare;

else

return num;

]

void countoccurence(int maxinum)

[

int occurence[128];

memset (occurence,0,sizeof(occurence));

if (maxnum > 128)

{

cout <<"<strong class="highlight">max</strong> <strong class="highlight">number</strong> cannot be more than 128"<<endl;

return ;

}

for(int trials = RAND_MAX; trials>0; trials--)

{

This answer is:
User Avatar

User Avatar

Wiki User

βˆ™ 10y ago

To find the minimum (or maximum) in any set of n numbers, assume that the first number is the minimum (or maximum) and then compare it with all the remaining numbers. If any number is less than (or more than) this number, then compare the remaining numbers with that number instead. When you've compared the entire set of numbers, you will have found the minimum (or maximum) in the set.

The following is an example using arrays of type int:

int min(int a[], size_t size)

{

size_t min=0, index=0;

while(++index<size)

if( a[index]<a[min] )

min=index;

return( a[min] );

}

int max(int a[], size_t size)

{

size_t max=0, index=0;

while(++index<size)

if( a[max]<a[index] )

max=index;

return( a[max] );

}

This answer is:
User Avatar

User Avatar

Wiki User

βˆ™ 11y ago

Let a, b, c be your three numbers. Then the required if-else condition statement is:

if( a>b && a>c)

printf("a is greatest");

else if( b>c && b>a)

printf("b is greatest");

else

printf("c is greatest");

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a program that reads in five integer and then determines and prints the largest and the smallest integers in the group?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What are the smallest and the largest integer values for primitive type short?

The smallest value is -32,768 and the maximum is 32,767


Read five integers and prints the largest and smallest integer using java?

{ // set up our input buffer BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String currentLine; // store our ints in a list int smallest = 0; int largest = 0; // counter int numIntsRead = 0; // force smallest and largest to start as the first proper int entered while (numIntsRead &lt; 1) { currentLine = in.readLine(); try { // convert from string to int int currentNumber = Integer.parseInt(currentLine); smallest = currentNumber; largest = currentNumber; ++numIntsRead; } catch (final NumberFormatException ex) { // we go here if the user didn't type in an integer } } // loop until we read all 5 ints while (numIntsRead &lt; 5) { currentLine = in.readLine(); try { // convert from string to int int currentNumber = Integer.parseInt(currentLine); if (currentNumber &lt; smallest) { smallest = currentNumber; } if (currentNumber &gt; largest) { largest = currentNumber; } ++numIntsRead; } catch (final NumberFormatException ex) { // we go here if the user didn't type in an integer } } // display our findings System.out.println("Smallest:\t" + smallest); System.out.println("Largest:\t" + largest); }


What is the largest value that can be stored in 64 bits represented in hexadecimal?

0xffffffffffffffff As an unsigned 64-bit integer, this represents the value 18,446,744,073,709,551,615. However, as a signed 64-bit integer, this only represents the value -1. The signed range is -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 making 0x7fffffffffffffff the largest possible positive value, and 0x8000000000000000 the smallest possible negative value.


Write a program that randomly fills a 10 component array then prints the largest and smallest values in the array?

final double[] ns = new double[10]; final Random rnd = new Random(System.currentTimeMillis()); // Fill... for (int i = 0; i &lt; ns.length; ++i) { ns[i] = rnd.nextDouble(); } // Get largest/smallest... double largest = Double.MIN_VALUE; double smallest = Double.MAX_VALUE; for (double n : ns) { if (n &gt; largest) { largest = n; } if (n &lt; smallest) { smallest = n; } } // largest and smallest are now the proper values.


Write a program that will find the smallest largest and average values in a collection of N numbers Get the value of N before scanning each value in the collection of N numbers?

#include #include #include int main(int argc, char *argv[]){int n, smallest, largest, sum, temp;if(argc < 2){printf("Syntax: foo val1[val2 [val3 [...]]]\n");exit(1);}smallest = largest = sum = atoi(argv[1]);for(n = 2; n < argc; n++){temp = atoi(argv[n]);if(temp < smallest) smallest = temp;if(temp > largest) largest = temp;sum += temp;}printf("Smallest: %i\nLargest: %i\nAverage: %i\n", smallest, largest, sum / (argc - 1));return 0;}

Related questions

What formula represents the largest of these integers if you are thinking of n consecutive positive integers and the smallest of which is m?

For x, which is the largest integer of nconsecutive positive integers of which the smallest is m:x = m + n - 1


Find the largest of three consecutive even integers if the sum of the 2 smaller integers is 16 more than the largest integer What is the largest of the 3 integers?

Let the smallest integer be 2n, the next integer is 2n + 2, and the largest one is 2n + 4. Then, we have:2n + (2n + 2) = (2n + 4) + 164n + 2 = 2n + 202n = 18 the smallest integer2n + 2 = 18 + 2 = 20 the next one2n + 4 = 18 + 4 = 22 the largest integerCheck


Why is the smallest positive integer is larger than the largest negative integer?

The smallest positive integer is 1. The largest negative integer is -1. 1 &gt; -1


What is the worlds largest integer?

There is no largest integers: they go on for ever.


Find three consecutive even integers such that if the largest integer is subtracted from four times the smallest the result is 8 more than twice the middle integer?

Suppose the middle integer is 2a. Then the smallest is 2a-2 and the biggest is 2a+2. 4 times the smallest is 8a-8 So largest subtracted from the smallest is (8a-8) - (2a+2) = 6a-10 So, 6a-10 = 2*2a = 4a so that 2a = 10 So the integers are 8, 10 and 12.


Find three consecutive even integers such that if the largest integer is subtracted from four times the smallest the result is 4 more than twice the middle integer?

If the largest integer is subtracted from four times the smallest, the result is 4 more than twice the middle integer. Let the smallest integer be x, then the others are x + 2 and x+ 4. Therefore 4x - (x + 4) = 2 (x + 2 ) + 4 Expanding, we get 4x -x -4 = 2x + 4 + 4 Gathering terms: x = 12 Thus the three integers are 12, 14 and 16.


Is the smallest positive integer larger than the largest negative integer?

YES


What is the sum of the four times the largest negative integer and the smallest positive integer?

-3


What is the largest possible negative integer?

-1: Negative integers become smaller as their absolute value increases. Therefore, the first negative integer is the smallest. This answer assumes that -0 is excluded because 0 is neither positive nor negative.


What is the sum of smallest and largest 5 digit whole number?

The smallest 5 digit integer is -99999. The largest 5 digit integer is 99999. The sum is therefore 0.


How do you arrange integers in decreasing?

Start with the largest and end with the smallest


What will be the algorithm to input n integers and output the largest one?

var largest : integer largest = array[0] for n : integer in array if n &gt; largest largest = n endif endfor return largest