#include <iostream>
using std::cout;
using std::cin;
using std::endl;
void input(double arr[], const int arr_size);
double max(double arr[], const int arr_size);
int main()
{
const int arr_size = 5;
double arr[arr_size] = {0.0};
input(arr, arr_size);
cout << "Highest number is: " << max(arr, arr_size) << endl;
system("PAUSE");
return 0;
}
void input(double arr[], const int arr_size)
{
cout << "Enter " << arr_size << " elements to find the highest:" << endl;
for (int i = 0; i < arr_size; i++)
{
cout << (i + 1) << " element is: ";
cin >> arr[i];
}
}
double max(double arr[], const int arr_size)
{
double highest_num = arr[0];
for (int i = 0; i < arr_size; i++)
{
if (highest_num < arr[i])
{
highest_num = arr[i];
}
}
return highest_num;
}
find even number in array
i want to write a simple without using pointer or array c program which will print greatest number when i give 20 number .........How far have you gotten so far?
If you have the series stored in an array, you loop through the array and print each array element in turn. Another possibility is to print out the numbers in the series as you generate them. In that case, you may not need to store anything (depending on the series, of course).
Yes but why.
Well the most prolific answer to this query would be the use of pointers.Use a pointer and allocate it to the array of interest and start printing.
find even number in array
You would insert this command right after your array values have been specified.document.write(name of array[Number on array this item is, starts at 0])
Java solutionFortunately, Java has a number of useful functions in the java.util.Arrays class for us.A call to...System.out.println(java.util.Arrays.toString(array));...will print out any array.
Loop through each array element; if it is even, print it out. The details, of course, will vary depending on the language; so I give it to you here in pseudocode: for i = 1 to (size of myArray) { if myArray(i) % 2 = 0 print myArray(i) } A syntax similar to "number % 2" is used in many languages to get the remainder of a division by zero. This lets you check whether the number is even (if the remainder is zero) or not.
i want to write a simple without using pointer or array c program which will print greatest number when i give 20 number .........How far have you gotten so far?
Create an array like so $numbers = array(); $numbers['0'] = "ZERO"; $numbers['1'] = "ONE"; and so on.. till you decide that's enough then to print it, echo the array with the desired key like so.. Example I print 5 in words echo $numbers['5']; which would print FIVE Good luck
Start Do 10 times read number if number > highest-number move number to highest-number end DO Print higest-number. end
read num1 read num2 sum = num1 num2 print highest value
If you have the series stored in an array, you loop through the array and print each array element in turn. Another possibility is to print out the numbers in the series as you generate them. In that case, you may not need to store anything (depending on the series, of course).
Yes but why.
Well the most prolific answer to this query would be the use of pointers.Use a pointer and allocate it to the array of interest and start printing.
maxValue = function (array) {mxm = array[0];for (i=0; i<array.length; i++) {if (array[i]>mxm) {mxm = array[i];}}return mxm;}; i don't know