C++ :: Find Highest Value Of Array

Nov 4, 2013

I am currently trying to make a simple method for an array that would find the highest value. here is currently what i got, but do not know what to change to make it correct.

double FindMax(double stock[], int size){
int size = stock.length();
int max = stock[0];

for(int i = 1; i < size; i++){
if (stock[i] > max)
{max = stock{i};}
}
return max;

View 3 Replies


ADVERTISEMENT

C++ :: Find The Lowest And Highest Temperatures?

Sep 29, 2013

How can I properly find the lowest and the highest temperatures?

#include <iostream>
#include <string>
using namespace std;

[Code]....

View 1 Replies View Related

C++ :: Find Highest Prime Of 600851475143

Jun 6, 2013

I have reduced it for lower numbers but for some reason with higher numbers when i get the program to out put all the primes they are in minuses!!!

I need a way to make this even faster, or maybe theres a better mathematical answer, I know that for numbers in their 1,000,000,000,000 have an average of 1 prime every 26.6 numbers (i think thats right there is 37,607,912,018 primes in the number 1,000,000,000,000) is there anyway i can utilize this??

#include <iostream>
using namespace std;
int main() {
int primeanswer = 1,p = 1;
for (int i=1;i<35; i++)

[Code] .....

View 19 Replies View Related

C++ :: Find The Highest Digit Within C-String

Oct 27, 2014

I can't find the highest digit within c-string. Ithe user was to enter 1234. the highest shall be 4 but can't get that number.

int Hnum(char* str) {
//int size = 0;
int H = 0, remainder, div =0;
int intstr = atoi(str);

[Code] ....

View 2 Replies View Related

C :: Find Highest Frequency Character In A String

May 17, 2014

The code shows all characters frequency, however i want to find which one has highest frequency

For example cprogrammmmming cboard
highest frequency: m

Code:
char string[100], ch;int c =0, count[26]={0};
printf("Enter a string
");
gets(string);

[Code] ....

View 3 Replies View Related

C++ :: Compare Data Stored To Find The Highest?

Aug 13, 2014

How do I compare multiple datas?

I have climate data for 6 months and is trying to find the highest climate month among all 6 months. How do I do that?

View 2 Replies View Related

C++ :: Find Average / Highest And Lowest Score?

Oct 9, 2014

Create a 1-D Array to hold a set of exam scores:

55 74 93 84 64 72 69 78 87 84 72 33 83 68 62 51 88 90

Write a program to do the following tasks:

1. Display scores in rows of four(4) scores.

2. Calculate average score and display.

3. Find Lowest score and display.

4. Find Highest score and display.

5. Find the deviation of each score, and display the score and its deviation.

6. Find the Standard Deviation and Display

7. How many scores are within One Standard Deviation

So I have the average down, but I am getting stuck at the part of displaying the highest and lowest score. Every time I run the program I get two giant negative numbers for both of them. I put all the scores into a .txt file and I just opened in through the program.

#include "TCHAR.h"
#include <iostream>
#include <fstream>
#include <iomanip>

[Code]....

View 1 Replies View Related

C/C++ :: How To Find Highest And Lowest With 3 Inputs In Different Control Statements

Aug 10, 2014

We will make it in Turbo C, C++ and VB.. but as of now (Turbo C and C++)

This is the problem

Make a program based on the given logic below

a>b && a>c - a highest
b>a && b>c - b highest
c>a && c>b - c highest
and will determined the lowest

we will do this in different program control statements:

1.If-Then-Else
2.Multiple-If
3.Nested-If
4.Do Case
5.Do While
6.Do Until
7.For Next
8.Switch
9.Break
10.Loop

is it possible?

View 1 Replies View Related

C/C++ :: How To Find Top 10 Highest And Lowest Numbers From Text File

Jan 3, 2014

I have a list of numbers with decimal point saved in a text file (grade.txt) like this:

80.2
85.7
57.2
90.0
92.9
74.0
76.5
...
I would like to write a small program to display the top 10 highest and lowest grade points.

View 3 Replies View Related

C++ :: Highest Value In The Array?

Nov 5, 2013

I don't know why im getting that error

#include <iostream>
#include <iomanip>
using namespace std;
int main () {
int const SIZE= 12;
double rainfall[SIZE];
double totalrainfall= 0;
for(int x=0; x<SIZE; x++)

[code]....

View 2 Replies View Related

C++ :: Finding Highest Number In Array

Aug 12, 2014

after staring at this for awhile, I can't figure out why it won't work. It prints out numbers from 0 to 100, but will print out an absurdly high number as the highest number, like 790 or 640. I can't see why.

Code:
#include <cstdlib>
#include <ctime>
#include <iostream>
using namespace std;
int find_highest(int array[]);
int find_highest (int array[], int size) {
int highest_num;
for (int i = 1; i < size; ++i) {
if (array[i] > array[i-1]) {

[code]....

View 1 Replies View Related

C/C++ :: Finding Highest Value In Array Using Functions

Mar 9, 2015

I keep getting an unresolved external symbol error in the double GetHighest function. Ive looked over the code many times and can figure out why its giving me this error.

//Question 1

// Copy source code below and save to a .cpp file (say lab11_01.cpp) and write statements to print what is indicated in the source code.
//In this question, you will implement code for finding the highest value in an array, and you do this in a function.
//This program gets a series of test scores and calculates and display the highest score.

#include <iostream>
#include <iostream>
#include <iomanip>
using namespace std;
// Function prototypes
void getTestScores(double[], int);
double getHighest(const double[], int);

[Code] ....

View 1 Replies View Related

C++ :: Using Array - Display Highest And Lowest Numbers

Oct 1, 2013

I have everything down except for the highest # and lowest number being displayed.

The arrays are 23, 4, 76, 89, 12, 43, 37, 67, 21, 14.

I have the average which is 38.6 but i stuck getting highest number and lowest.

View 7 Replies View Related

C++ :: Stuck On Getting Highest Number Output Using Array

Feb 25, 2014

Here is my code and everything works except i can not get the highest array number to be output. it always says 10.

My instructions are:

(1) Create a 10-integer array called data
(2) Set a pointer ptr to point to array data
(3) Output the elements in array data using pointer ptr
(4) Find the largest element in the array data using pointer ptr

#include <iostream>
#include <cstdlib>
using namespace std;

[Code].....

View 4 Replies View Related

C/C++ :: Finding Highest Frequency From Array Of Characters

Jan 27, 2015

I have been working on a project that deals with an array of characters and finding there frequencies. I was able to determine the frequencies that where greater than 1, but I need to find the HIGHEST frequency.

Here is my full code:

#include <iostream>
using namespace std;
void input(char unlisted[80], int& n);
void bubblesort(char unlisted[80], char sortedlist[80], int n);

[Code].....

As you can see this will print out all frequencies that are bigger than 1, but I only want the highest frequency. Basically I want to print out all frequencies when count is greater than 1 less than count, but because its in a loop count will always be greater than count-1 so it prints out all frequencies.

View 3 Replies View Related

C++ :: Finding Lowest / Highest In Multi-dimensional Array

Mar 25, 2013

I have this multi-dimensional array. There are 12 rows, each represents the months, and 2 columns, the 1st column represents the lowest temperature and the 2nd column represents the highest temperature.

I need to find the lowest temperature in only the first column and the highest in only the 2nd column.

This takes in the temperatures. LOHI = 2, MONTHS = 12, LOW = 0, HIGH = 1

void PopulateTemp(int temp[][LOHI])
{
for(int month = 0; month < MONTHS; month++)
{
cout << "Month " << month+1 << endl;

[Code]......

My professor said we only needed 1 for loop as you only need to read the data from one column in each?

View 10 Replies View Related

C/C++ :: Sorting Array And List Totals From Highest To Lowest

Jun 8, 2014

I am doing a modification to a school project call rainfall statistics. I have that written, but need to sort the array and list rainfall totals from highest to lowest. I thought I knew what I was doing but I am having some difficulty locating all my errors, the error I keep getting now is:

1>------ Build started: Project: Rainfall Statistics Program, Configuration: Debug Win32 ------
1> Rainfall-main.cpp
1>Rainfall-main.cpp(88): error C2601: 'sortHighest2Lowest' : local function definitions are illegal
1> Rainfall-main.cpp(25): this line contains a '{' which has not yet been matched
1>Rainfall-main.cpp(96): error C2065: 'TOTAL_NUM_OF_MONTHS' : undeclared identifier
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Below is my code, I know i'm missing something, just can't see it.

#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

//Here are the function prototypes
double getTotalRainfall(double[], int);
double getAverageRainfall(double[], int);

[Code] .....

View 2 Replies View Related

C/C++ :: Function To Return Lowest And Highest Values In Array

Mar 8, 2014

// I believe my loop for the functions work but the values are not returning !

// Acoustic data

#include <iostream>
#include <fstream>
using namespace std;
double low( double []);
double high( double []);
void readArrayr( double [], double , double);

[Code] .....

View 6 Replies View Related

C++ :: Using Array Of 5 Scores And Calculate Average / Highest And Lowest Score

Apr 11, 2013

it compiles and runs, it gives me the average and the highest score but says lowest is 0 even though 0 is never entered.

Write a program which uses an array of 5 scores and calculates the average score, the highest score and the lowest score.

#include <iostream>
using namespace std;

int getHighest(int [], int);
int getSmallest(int [], int);
double getAverage(int [], int);
int count;
int numbers;

[Code] ......

View 2 Replies View Related

C++ :: Sorting Elements Of Array In Order From Highest To Lowest Values

Jul 6, 2013

I am writing a function called swap that sorts the elements of an array in order from highest to lowest values where they descend and ascend. A particular thing about this function is that swap does NOT re-arrange elements in the array so it just uses a second array of indexes for the elements in the original array and then swap sorts the second array based on the values in the original array. A sorted version of the original array can then be produced with these sorted indexes. You can declare and initialize the original array without any user input.

For example, int arr[10] = {1, 5, 22, 14, 6, -5, 7, 9, 12, 15 };

Header of the function swap must be as shown below: void swap(int array[],int swapedIndexes [], int size, char mode) When mode is 'a', the function sorts the array in the ascending order, and when mode is 'd', the function sorts it in the descending order. int swappedIndexes[5];swap(array,swappedInde… 5, 'a');

So far I have this code that randomly generates arrays of 10 elements and I found the max and min, but I am confused on what to do about the swapping part? Also, how to make the numbers ascend or descend in numerical order?? Here is what i have done so far:

#include<ctime>
#include <iostream>
using namespace std;
int min(int [],int);
void max(int [],int , int &);
void main()
{ srand(time(0));
//1-declare

[Code] .....

View 1 Replies View Related

C++ :: Array Searching - Display Highest And Lowest Number From User Input

Aug 26, 2013

I am having a problem printing out the results for my code, It is supposed to print out the largest and smallest value in the array, but keeps giving me a value not entered and I don't know why.

//This program lets the user enter 10 numbers and then display the highest and lowest number.

#include <iostream>
#include<stdio.h>
using namespace std;
int main() {
const int NUM_ENTERED = 9;
int number[NUM_ENTERED], highestValue = number[0], lowestValue = number[0], count=0;

[Code] .....

View 2 Replies View Related

C++ :: Using Array To Accept 10 Test Score - Print Highest / Lowest And In Reverse Order

Jan 28, 2014

Using the array to accept 10 testscore. Calculate and print the highest, lowest, fifth test score entered and all the test score entered in reverse order.

How i would get it to print the highest,and lowest and in reverse order. I'm confused as to what to do...

View 4 Replies View Related

C :: How To Find Maximum Value Of Array

Oct 29, 2014

Any way to determine the highest value of an array I created with random numbers. I am confused because the array needs to be initialized in the main, but populated in a function. I was able to populate it using a pointer variable and my results came out good for the initial array values and elements.

In order to figure out the max, I think I would need the results of the populated array. How do I do this when the populated array is stored in a pointer variable? Would I need to create a pointer to the first pointer I created? I tried creating another pointer to the initial array and printing that, but my results were not good.

Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

[Code].....

View 10 Replies View Related

C++ :: How To Find First Element In Array

Oct 7, 2013

Lets assume, I use array of 100 the i input 50 element and now i want to find which one is first in array... without using pointer ...

View 2 Replies View Related

C++ :: Find Median Of Array?

Jul 4, 2013

I am trying to find the median of an array in c++.

This is the array that I would like to find the median for.

scores[14] = {62,70,98,71,81,99,74,80,73,88,73,72,95,71};

View 5 Replies View Related

C++ :: How To Find Mode In Array

Feb 6, 2014

How do you find a mode in array? This is what i got so far. I put this after i sort the array

for (int index = 0; index < size2; index ++) {
//count[mode[index] - 1]++;
if (mode[index] == mode[index + 1]) // compare the first to sec array {
again++;
cout <<"This is number " << again << endl;
}
}

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved