#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
#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--)
{
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] );
}
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");
The smallest value is -32,768 and the maximum is 32,767
{ // 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 < 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 < 5) { currentLine = in.readLine(); try { // convert from string to int int currentNumber = Integer.parseInt(currentLine); if (currentNumber < smallest) { smallest = currentNumber; } if (currentNumber > 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); }
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.
final double[] ns = new double[10]; final Random rnd = new Random(System.currentTimeMillis()); // Fill... for (int i = 0; i < 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 > largest) { largest = n; } if (n < smallest) { smallest = n; } } // largest and smallest are now the proper values.
#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;}
For x, which is the largest integer of nconsecutive positive integers of which the smallest is m:x = m + n - 1
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
The smallest positive integer is 1. The largest negative integer is -1. 1 > -1
There is no largest integers: they go on for ever.
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.
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.
YES
-3
-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.
The smallest 5 digit integer is -99999. The largest 5 digit integer is 99999. The sum is therefore 0.
Start with the largest and end with the smallest
var largest : integer largest = array[0] for n : integer in array if n > largest largest = n endif endfor return largest