Visual C++ :: Error In Finding Lowest Double In Array
Oct 25, 2014
When I run the program, when it displays the lowest temtpature, it shows the address instead of the actual number.
Code:
/*********************************************
* File: b.cpp
* Description: Create a C++ program that declares a 100-element array of doubles representing temperature readings. Pass the array to a function to be partially filled by the user. When the user is done entering temperatures, the function should return the number of elements added to the array. The main function should then display the maximum and minimum temperatures in the array.
***********************************************/
#include <iostream>
using namespace std;
//prototypes
void getData(double arr[]);
[Code] ....
View 2 Replies
ADVERTISEMENT
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
Aug 3, 2014
How to find a lowest grade in programing using the c++.
example: {65,89,100,76,80}.
#include<iostream>
using std::cout;
using std::endl;
int main() {
float grade=0;
[Code] .....
View 1 Replies
View Related
Nov 11, 2014
I dont know why I cannot get the lowest leftmost node in BST: segment fault
goToLeaf=root;
//now traversing right subtree from root node
else if(strcmp(curr->barcode, traverse->barcode)>0){
path='R';
traverse=traverse->right;
save=traverse;
cout<<"Right subtree exists. Value in right subtree"<<endl;
[Code] .....
Need this to delete node in two subtreed right subtree
View 2 Replies
View Related
May 19, 2014
I know how to find the occurrences of a character in a string, but I have a more specific problem.
For example, consider the string:
" C 1.3825 4.0000 12.0000 1.9133 0.1853 0.9000 -1.1359 4.0000 "
I want to extract a vector that contains the positions of every first character for each number.
For the example above, the output should be a vector with elements [6 15 23 33 etc...]. These are the positions of the first character for every number.
I need to be able to do this for any arbitrary string with any arbitrary amount of numbers and characters in it (I also need to account for negative numbers).
View 1 Replies
View Related
Aug 16, 2014
In a record I have IDs of type int but some may repeat. These IDs also got sales of type float. I wish to compare the IDs number of times they appear and of match found accumulate their sales and put it in another struct. However if an ID is found which is new I pass it to a function to initiate sales..but my code never reach second ID, given I am trying with two IDs.. given IDs in transFile
ID Sale
12345 870
90909 100
I enter these two in transFile and match it with masterRecord. 12345 is matched and updated likewise but 90909 is never executed or matched in checkID function..
void sync_trans_files(unsigned short int count, master masterRecord[], char transFile[]){
const short int weeklyemployee=25;
//read number of records from transFile;
struct trans{
[Code].....
View 8 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
Sep 22, 2013
I am getting an error...
Error1error C2109: subscript requires array or pointer type451
PHP Code:
#include "stdafx.h"
#include <conio.h>
#include <iostream>
using namespace std;
//Function prototype
int searchList (const int [ ], int);
[code].....
View 3 Replies
View Related
Aug 3, 2013
How do I find an error in a multithreading program (written in C)? I get an address, but when I put it into psp-addr2line, i get
??
??:0
View 2 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
Sep 12, 2013
I have written a delete node function to delete a node in a linked list by the index number. Here is the code:
Code:
void delete_node(struct node **start,int index_no)
{ int counter=0;
struct node *current=*start, *prev=NULL;//Current holds start and prev holds previous node of current
while(current->next!=NULL)
[Code]....
note that I know if the head node turns out to be the indexed position, there is no way to delete that node in the current coding. But please after correcting the present node add that part of the code separately.
View 5 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
Dec 27, 2013
I have std::vector of players and each player have its own value. The value is of the type double, but the original value are of the "XX.00".
Now what I'm trying to do is to insert a player into this vector. For that I need to find a place and to find a place I need to compare player value.
So lets say I have a player in the vector whose value is 24.00 and I am trying to insert a player whose value is 25.00. To my surprise MSVC 2010 tells me that:
24.0000000000000 == 25.00000000000
I do aware that comparing double type is not going to work like this, but I would expect not to have such big of a difference. ;-)
Why this comparison is true and how to eliminate such thing?
View 3 Replies
View Related
Nov 22, 2013
I have the following piece of code:
string ss = findNodeValue( str, "Horizon");
cout << "ss is: " << ss << endl;
double dd = atof( ss.c_str());
cout << "dd is: " << dd << endl;
When the value of 'ss' is printed, I find it prints 1.0, but when the value of 'dd' is printed, it prints 1 whereas it is supposed to print 1.0.
View 2 Replies
View Related
Jul 31, 2013
1) What is the range of numbers covered by a 64-bit double?
2) Ignoring fractions, is the above range wider or narrower than the range covered by an int64?
View 14 Replies
View Related
Sep 5, 2013
I receive a byte stream. The first 8 bytes contain an Identification number. I receive at first the lowest byte and at the end the highest byte of the number. How can I transform this into a double value and later back into the bytestream? In the past I hard only 2 Byte values and there I could use things like MAKEWORD and HIBYTE and LOWBYTE to convert the values
View 4 Replies
View Related
Sep 19, 2012
I'm trying to remake my Windows screensaver written with C++ and WinAPIs to work on multiple monitors. I found this article that gives the basics. But when I implement it in my own code, I get a weird result. Take a look at this code:
Code:
case WM_PAINT: {
PAINTSTRUCT ps = {0};
HDC hdcE = BeginPaint(hWnd, &ps );
EnumDisplayMonitors(hdcE, NULL, MyPaintEnumProc, 0);
EndPaint(hWnd, &ps);
[code]....
Painting always works on a primary monitor. But when I paint to the secondary monitor, I can only paint directly to its DC. When I use double-buffering technique (with DIRECT_PAINT pre-processor directive commented out) I only get a black screen on a secondary monitor when it should've been red.
First one with direct painting that works:
and then the one that doesn't, with double-buffering technique:
View 12 Replies
View Related
Dec 15, 2014
I am programming about some numerical problems. I know that vector supplies vector operations. But vector always allocate more memory (used when the size changes). My matrix or array never change size, and the vector operation is just +,-,dot,cross,distance
My question is that should I use vector, or simple double array with new & delete is enough for me?
View 6 Replies
View Related
Dec 20, 2014
The assignment is to create a program that lets users reserve a spot on a plane either in coach or first class. I'm supposed to create a .txt file to use as the prices for different seats and while I have done that, I'm having trouble getting the file into a double array.
This is what I have so far.
//This program lets the user reserve airline tickets on a plane
#include <iostream>
#include <cstring>
#include <fstream>
using namespace std;
[Code]....
Once I have the file into a double array, I have to use that array to implement it into the seat prices. Such as if user chooses to sit in row 1 seat 1 it would be that price. Also the '#' means open seat and '*' means seat taken. O yea, under the "//Populating the double array" is me trying to see if a for statement or a nested for statement would work.
View 5 Replies
View Related
Oct 30, 2013
I've been trying to get the numbers for hours now but i can seem to get it right. Here's the problem below:
During the initial period, when the heater is not yet functioning at peak efficiency the heating will increase the temperature inside the building at a rate given by the following equations. During the initial period when the air conditioner is not yet functioning at peak efficacy the air conditioner will decrease the temperature inside the building at a rate given by the same equations.
Interval = (Time since turning on / 2.0 ) - 3.0
Factor multiplying Temperature change per minute = exp( Interval) / ( 1 + exp(Interval) )
These equations can also be used after the heating or air conditioner reaches peak efficiency. These equations converge to 1, so after the heating or air conditioner reach peak efficiency these equations will always give a value of 1.
the value of these equations needs to be multiplied by the RATE TEMPERATURE CHANGES. The RATE TEMPERATURE CHANGES is EITHER the change in temperature inside the building in degrees Celsius per minute caused by heat being extracted by the air conditioning OR the change in temperature inside the building in degrees Celsius per minute caused by the heat being generated by the heating .Temperature change in degrees per minute = Factor multiplying Temperature change per minute * RATE TEMPERATURE CHANGES
Temperature at end of this interval = Temperature at the start of the interval + temperature change due to heat escaping during the this interval + temperature change due to heat generated by the heating system during this interval + temperature change due to heat removed by the cooling system during this interval
i have a:
...rate of -.05 for heat escape w/o cooling or heating
...rate of 0.10 for heat escape w/ cooling
...rate of 0.125 for heat increase w/ heating
...Starting temp=38.00
...Time interval 3.50
I can't seem to find the temp at the ending interval? What i tried doing:
Code:
#include<iostream>
#include<cmath>
using namespace std;
int main () {
double intervals=0.00;
double tempPerMin=0.00;
[Code] ....
The temperature at the end of the interval is suppose to be 37.81 but i can't get the answer. I'm pretty sure this is a logical error from the equations i used but i can't seem to find it.
View 3 Replies
View Related
Mar 6, 2015
How to convert char array into double?,i.e. store char array values into a single double variable. Below is the code that i'm working. Im extracting the value "2255.1682" from char array gpsdata1. I used while loop, extracted the value and stored in "myChar", but i want to store it in double variable "lat1".
Code:
#include <stdio.h>
#include <stdlib.h>
int main(){
unsigned char gpsdata1[]="$GPGGA,091310.000,2255.1682,N,11356.3605,E,1,4,1.62,164";
char myChar;
double lat1;
[Code] .....
View 5 Replies
View Related
Aug 1, 2013
How to initialize double pointer array..?
int (**aLines)[2];
View 3 Replies
View Related