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
ADVERTISEMENT
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
View Related
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
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
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
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
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
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
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
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
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
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
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
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
Aug 3, 2014
Now I know there's a simple way to calculate highest value. But here i have this algorithm which i understood part of it.
I know that *largest is point to the first element of begin which is 5. so in the first if statement its 5<5 at the first iteration ?
// i marked the parts i didnt understand with " //"
Code:
#include <stdio.h>
int *print(int *begin ,int *end ){
if(begin==end)
return 0;
int *largest = begin;
[Code] ....
View 10 Replies
View Related
Feb 17, 2013
Basically, I am suppose to compute 10 numbers and find their highest prime number for each of them. I've already have the inputs working, and set up 2 arrays to store inputs and their highest prime number. But I am uncertain on how to find and store their highest prime number. How to start it off?
View 7 Replies
View Related
Aug 14, 2012
i wnt to display student who get highest marks among them...i have code for finding maximum marks from them but don't kne how to print only top 5 student...
Code:
static void Main(string[] args)
{
Console.WriteLine("Please Enter Number of Students :");
int n = Convert.ToInt32(Console.ReadLine());
StudentDetails[] student = new StudentDetails[n];
for (int row = 0; row < n; row++)
{
Console.WriteLine("Please Enter Student name :");
[Code]...
(dis code in Visual Studio)
View 6 Replies
View Related
Dec 14, 2014
it's not my primary language, so my code variables are in my language.
Code:
FILE *eng;
eng = fopen("eng.txt", "r");
if(eng == NULL){
[Code]....
fclose(eng); It's a piece of my code. Some explanation: From file, where is full of words under selves. I cut it on word and from word i'm printing:
1) word
2) how many letters in the word
3) word backwards and
4) viz. problem is down
For first: There i have warning: while(feof(eng) == NULL); like (comparison between pointer and integer) i don't get it. For second i have a big problem. I must from every word print the most recurring character.
For example: nondeterministically -> the most are N and I. And if, there is more then one most reccuring char, you choose one of them.
View 5 Replies
View Related
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
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
Feb 26, 2013
I'm having trouble, I want the inner loop to display the lowest and highest score. If I assign initial values for the high and low score, it won't always work (because if no/ all scores are above/ below my initial values...)
But without assigning initial values for highscore and lowscore, One of them will always be undefined during the first runthrough.
#include <iostream>
using namespace std;
const int AGRADE = 90;
const int BGRADE = 80;
const int CGRADE = 70;
const int DGRADE = 60;
int main() {
[code]....
how do i set this up so it stores a low and high score, and then compares those to each next number in the series?
View 6 Replies
View Related
Mar 12, 2014
I am trying to calculate the largest and smallest values using functions. I keep getting this (pointer-to) error
#include <iostream>
#include <conio.h>
using namespace std;
void getValues(int [], int);
void displayValues(const int[], int);
int largest(const int[],int);
int smallest(const int[],int);
void displayLargestSmallest(int,int);
[code]....
View 3 Replies
View Related
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
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
Apr 7, 2013
I cannot get this program from having a continuous loop. I need to have a user-defined loop.
Here is what I have so far:
Code:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
int a,b,c,high,med,low;
[Code] ....
View 7 Replies
View Related
Sep 28, 2014
How do i sort numbers from highest to lowest using qsort? I dont have a code. I dont know how to use this one.
View 1 Replies
View Related