C++ :: Function That Will Take 3 Ints And Find Sum Of Higher 2

Mar 12, 2014

I am trying to figure out the larger 2 out of 3 integers when i call them into a function from main program so far i have . How to write a simple function that will take 3 ints and find the sum of the higher 2?

Code:

int findsum(int a,int b,int c)// will find the highest int and return it to our main program {
int max,max2;// this sets our local variable max
// next we will find the larger of our first 2 variables
if( a>=b)

[Code]....

How to get the second highest number and add it to max...

View 4 Replies


ADVERTISEMENT

C++ :: Find Values That Are Higher / Lower Than All 8 Of Their Neighbors

Nov 19, 2014

I have to do a project where a file with 60 rows and 17 columns is stored in an array. The purpose of the project is to find all the "peaks" and "valleys". A peak is considered a number that has a higher value than all 8 of its neighbors, while a valley is a number that has a lower value than all 8 of its neighbors. Here is an example where peaks are bolded and valleys are underlined.

2558632321342150
3245434041323027
3440383936283035
4045424832342932
3939404247492730
3131313232334435

I'm having trouble coming up with the code that will find values that are higher/lower than all 8 of their neighbors.

View 4 Replies View Related

C/C++ :: Program To Find Min / Max Values Of Two Ints / Doubles And Chars

Jan 31, 2015

I'm supposed to create a program that will find the min/max values of two ints, doubles, and chars, It's not completely done but here's what I have so far.

It's giving me an Error 1 error LNK2019: unresolved external symbol "public: __thiscall MinMax<int>::MinMax<int>(int,int)" (??0?$MinMax@H@@QAE@HH@Z) referenced in function _mainC:UsersDerickDesktopCiss243Week3 Assignment2Week3 Assignment2Main.objWeek3 Assignment2

Header file
#ifndef MINMAX_H
#define MINMAX_H
#include <iostream>
using namespace std;
template <class T>
class MinMax

[Code] ....

I don't know why the site is adding in extra bits of code like /> in certain areas, it's not there when I paste it in and it's not in my code ....

View 5 Replies View Related

C/C++ :: Converting String Of Ints To A Vector Of Ints?

May 8, 2014

I am getting a string from the consle and that all works fine. I'm expecting a string of number, ie 123456.... I store that fine in my string object. I then need to take each individual number, ie 1, and put it in a vector then take the next number, ie 2, and put that in the next element in my vector.

Everything i've found and does eaither takes the entire string and stores it as an int, or takes the ascii representation of the number and stores that. How do I seperate each individual number and store them seperatly. below is a few different variations i've tried that doesn't produce my desired results.

cout<<"Please type the memory memory frames (numbers 0-9) to be used to simulate the input memory "<<endl;
cout<<"Your input: ";
string line="";
cin>>line;
cout<<"
Please wait while your input is processed and validated..."<<endl;

[code].....

the only thing i havn't tried yet is string streams and i don't necessarly like using them. Am i going to have to go that route? will that even work?

EDIT:I forgot to mention that this is being done on linux and then ported to unix.

View 7 Replies View Related

C :: Printf Ints That Are Modified In Another Function?

Feb 13, 2013

I have gotten it to record the date and I can printf it either on the same function, or in the main(). However, one of the requirements I must adhere to is to printf the statement in a brand new function, but when I do that, it just doesn't work. Heres what I mean:

Code:

#include <stdio.h>
#define TICKER "LRCX"
#define INVESTMENT_AMOUNT "10,000.00"
//Prototypes
int getdate(int* month1,int* day1,int* year1,int* month2,int* day2,int* year2);
float getprice(float* BPrice, float* SPrice);
void printdate(int month1, int day1, int year1);
}

[code]....

View 3 Replies View Related

C/C++ :: Get Random Number Under Or Higher 10

Jun 5, 2014

I was trying to get random number under a specific number. I used this code below to get random number under the number 10.is there another way to get this result,too?

#include <iostream.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main() {
int mynumber = rand() % 10+1 ;
cout << mynumber ;
return 0;
}

is there a way to get a random number, bigger than a specific number(for example,number 10)

View 8 Replies View Related

C/C++ :: Print Even Then Odd Ints From Stack

Feb 19, 2014

Given a stack with an equal amount of even and odd numbers: 4, 22, 15, 3. The output should be in any order: [even], [odd], [even], [odd].

int main() {
Stack<int, 4> stk; stk.ClearStack(); int x;
for (int i = 0; i < 4; i++) {
cin >> x;
stk.PushStack(x);

[Code] ....

Output is:

Wed Feb 19 20:09:10 2014
4 7 5 22 //input
22 5 4 //output

Press any key to continue . . .

I know the logic fails if the first number is not even, but I cant seem to figure out another way to do it.

View 14 Replies View Related

C++ :: Struct Of Ints Via Socket?

Feb 7, 2014

I have some paper work to do about a game I should be able to play with my class mates. We should be able to send and recive a struct concerning about the 'moves' of the pieces at the game. This struct is made of 4 ints, simple as that.

I had a previous paper work to do where I'd have to send ints and that was ok, but now that I have to send a struct I'm failing to do so. This is What I've tried:

//SERVER
struct message{
int code;
int piece;
int x;
int y;
}send;
bytes_sent=write(new_socket,&send,sizeof(message));
cout<<bytes_sent;

So far so good, I see 16 as bytes_sent's value.

On the other hand:

//CLIENT
struct message{
int code;
int piece;
int x;
int y;
}recive;
bytes_recvd=read(my_socket,&recive,sizeof(message));
cout<<bytes_recvd;

I always see 0 as the bytes_recvd's value.

View 3 Replies View Related

C++ :: Getting Multiple Ints From String Data

Feb 18, 2013

I'm having trouble making a .obj loader at present I'm trying to load faces that are defined as follows:

f 1/1/1 2/2/2/ 3/3/3

So far I've separated the the three number groupings into three strings, I've had a few issues with stringstreams and would like a simple solution.

View 1 Replies View Related

C++ :: Passing Ints To Void Functions

Mar 19, 2014

At first i had my int variables in global scope however i cant do the so im trying to pass my variables from my main to the void functions but cant.....

View 1 Replies View Related

C++ :: Generate Lists Of Permutations Of Ints

Jul 26, 2014

I am trying to generate some lists of permutations of ints but I can't make std::next_permutation work for me. The problem is I need to include permutations which don't use every number. For example take the array of numbers [1, 2]. I need an algo that will return:

1
2
12
21

Must work with up to 8 numbers.

View 5 Replies View Related

C/C++ :: Get Fstream / Ostream / Ifstream To Save Ints Then Load Them

Jun 5, 2014

I have been trying to figure this out for a text based game. Lets say your money is 500. Then you save your game, but when you start the game the starting is 50, so when you load it, you still have 500 money, I tried lots of test, and im having trouble?

View 10 Replies View Related

C/C++ :: Loop To Add Ints / Strings Into Vector In Ascending Order

Feb 24, 2014

The code is supposed to take either an int or a string (and their respective vectors) and insert a given int or string into the vector in ascending order. My code works properly for ints, but it's having a problem with strings.

The order I get with the strings given is

penguin
banana
great
jungle

For some reason comparing penguin to banana/great doesn't give the expected result. The template attached only includes the function and the private vectors needed for the function.

template<class T>
class orderedList {
public:
void insert(const T& item);
private:
vector<T> list;
int total = 0;

[Code] ....

View 11 Replies View Related

C/C++ :: Atoi Does Not Work / Converting Cstring Vector Into Ints

Feb 18, 2015

I have saved the contents of an int vector to a txt file and the numerical data was converted into a c-string. Nov I need to import and read the contents back into my program but I have not been able to convert c-string numerical data back into ints.

View 1 Replies View Related

C :: Write Program To Sort 2 Ints On Ascending / Descending Order?

Jan 24, 2014

I'm trying to write a program to sort 2 ints on ascending/descending order, using function pointers. here is my code so far:

Code:
#include <stdio.h>
#include <stdlib.h>
int min_el(int a,int b);

[code]....

View 6 Replies View Related

C# :: Creating Complex Number Calculator - Convert String To Ints

Sep 18, 2012

I am working on an assignment to create a Complex number calculator. In this assignment I am to ask the user for input to the calculator. We are given a sample run output that looks like this.

Enter operand1: 3 4
operand1: (3, 4)
Enter operation : +
Enter operand2: 1 2
(3, 4) + (1, 2) = (4, 6)

My question is how would I take from the user: an integer followed by a space followed by another integer and convert that into two seperate accessible int values that I can save as real and imaginary values.

View 4 Replies View Related

Visual C++ :: Control Structure Outputting Wrong Iterations Via Ints?

Mar 18, 2013

I have this:

Code:
for (chr_min = 0; chr_min <= 24; chr_min += 3) {
strOut = "";
for (ctr_row = 1; ctr_row <=3; ctr_row++) {
switch (ctr_row) {
case 1:
strOut = strOut + Line1.substr(chr_min, 3);

[Code] ....

it is outputting to the shell window, this:

Code:
1
1
1
2
2
3

and that pattern apparently repeats for every iteration that's specified in the outer loop. am I missing something here?

View 14 Replies View Related

C/C++ :: Find The Address Of Function?

Oct 14, 2012

find the address of function? mail the ans on (email removed)

View 4 Replies View Related

C++ :: Function To Find Out Iterator Of Certain Value In Vector

Sep 4, 2013

I defined the following function to find out the iterator of a certain value in the vector. I defined it as such so if the value exist in the vector then return a iterator of it, if not then return a pointer pointing to nonsense.:

vector<tIndex_t>::iterator unlabelTit(const tIndex_t index) {
for(vector<tIndex_t>::iterator it=unlabelT.begin(); it<unlabelT.end(); it++) {
if(index==*it) return it;
} return NULL;
}

But looks this one is not accepted by compiler, saying I cannot do this kind of comparison like:

unlabelTit(i)!=NULL;

so I just delete the return NULL; and then the compiler giving me warning about no return statement before }.

a pointer pointing to nonsense? how to do that?

View 3 Replies View Related

C/C++ :: Using Function To Find Mode Of Array?

Oct 20, 2014

My code seems to find the mode of the array I input sometimes. Sometimes it gives me the wrong number or multiple numbers. It just all depends on what is number is inputted into the array. I don't know what the problem is. I tried looking online and editing many times and can't find the answer. Maybe I'm overlooking something or doing something wrong. Here's my code.

#include <stdio.h>
void readArray(int arr[], int length)
{
printf("Enter data:
");

[Code].....

Maximum: 15
Mode: 2

As you can see the mode is clearly not 2 and I do not know why.

View 8 Replies View Related

C/C++ :: Classes - Find Factorial Of Any Given Function

Aug 2, 2014

I wrote this code to find the factorial of any given function ., works fine but when i put it in a class... it gives me an error ::assignment of read only variable fact;

#include <iostream>
using namespace std;
const static int fact=1;
class My_Factorial {
public:
int x;
void Get_Number(){
cout<<"enter a number to find its factorial";

[Code] ....

View 3 Replies View Related

C/C++ :: Find Max And Min Value In Void Function Using Pointers

Aug 31, 2014

I'm having issues with pointers and relationship operators in C.

I need to find a max and min value in a void function using pointers. max and min would work if they had values. mul works, because you can just do math operations with pointers.

There are 0 errors and warnings; but max and min are never going to work as is.

Clearly I'm missing something.

#include <stdio.h>
#include <stdlib.h>
void max(int *a, int *b, int *c, int *d, int *result);
void min(int *a, int *b, int *c, int *d, int *result);
void mul(int *a, int *b, int *c, int *d, int *result);
int main()

[Code]...

Your job will be to create a program that uses pointers. Your output must be done in the main function and the calculations MUST be done in the three functions. Therefore you MUST use pointers correctly.

You must declare and implement the following 3 functions. Below are the three prototypes that you must use in this program.

void max(int *a, int *b, int *c, int *d, int *result);
void min(int *a, int *b, int *c, int *d, int *result);
void mul(int *a, int *b, int *c, int *d, int *result);

The functions have the following meaning:

max
finds the max value of a,b,c,d and stores the largest value in result.
min
finds the min value of a,b,c,d and stores the largest value in result.
mul
multiplies a * b * c and divides by d. Stores that value in result.

Below is an example input/output. This input will be read in via the keyboard (use scanf).

input
output (note that user input is shown in bold)
1 2 3 4
Enter the 4 numbers: 1 2 3 4
The max is 4. The min is 1. (a * b * c) / d = 1
100 3 201 103
Enter the 4 numbers: 100 3 201 103
The max is 201. The min is 3. (a * b * c) / d = 585

Your output MUST match exactly the output below for the input from above. Your program must compile, failure to do so will result in 0 points. */

View 9 Replies View Related

C/C++ :: How To Find Address Of Library Function

Nov 30, 2012

I want to find the address of printf() in c.

View 2 Replies View Related

Visual C++ :: Cannot Find Function DlgProc

Apr 9, 2014

The code is bulit for the x64 platform with unicode enabled.

Code:
class CameraExporter : public UtilityObj {
static INT_PTR CALLBACK DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
};
void CameraExporter::BeginEditParams(Interface* ip,IUtil* iu) {

[Code] .....

Error2error LNK2019: unresolved external symbol "public: static __int64 __cdecl CameraExporter::DlgProc(struct HWND__ *,unsigned int,unsigned __int64,__int64)" (?DlgProc@CameraExporter@@SA_JPEAUHWND__@@I_K_J@Z) referenced in function "public: virtual void __cdecl CameraExporter::BeginEditParams(class Interface *,class IUtil *)" (?BeginEditParams@CameraExporter@@UEAAXPEAVInterface@@PEAVIUtil@@@Z)e:Jackydocumentsvisual studio 2010ProjectsCameraExporterCameraExporterCameraExporter.objCameraExporter

View 2 Replies View Related

C++ :: How To Implement Mean1d Function To Find Mean

Nov 2, 2013

Code:
#include <iostream>
using namespace std;
int main() {
//I'll be making a 1 dimensional array
int array1d[25];

[Code] .....

View 1 Replies View Related

C++ :: Function To Find Out How Many Days Have Passed Since Last Birthday

Feb 20, 2013

I have to write a c++ program with my own function which consists of two parameters (day, month). Function have to return number of days since the begining of this year. Using this function i have to find out how many days are left till birthday (or how many days have passed since last birthday)

This is how far i am:

Code:

#include <iostream>
using namespace std;
int cikDienu(int diena, int menesis);
int main()

[Code] ....

View 9 Replies View Related







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