I need addition array1 array2 in new array before I make this program but the values of array1 and array2 there are in code c# that is worked without problem.
But now i need the user enter the values of arrays, i make that but i failed in addition array1 and array2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyArray {
#include<iostream.h> #include<conio.h> class vector { float x_comp1,y_comp1,z_comp1,x_comp2,y_comp2,z_comp2; float add_x,add_y,add_z;
[code]....
Now the problem is that when i run the program, i get correct value of the two vectors, but i am not getting the right value for the addition...it might be the x_comp1 and so on are not getting those values even i am assigning them..
1)What should be the best variable for adding two 6-digit hexadecimal,such as 0034AD,0057EA? I would like to use array of character but it seems hard to handle.
What my ultimate goal here is to make a program that asks the user how many numbers they would like to add followed by asking the user what numbers they want to add. I want the amount of numbers they can add to be infinite and have the loop continue adding the numbers until it reaches the final number. I just need to know how to do this.
Here's my code:
#include <iostream> #include <string> using namespace std; int main() { //variables int amount; float num; float sum;
i new to c++ programming. i have a program due soon in vector addition. i am to design should be able to add vectors with certain magnitude and direction and give its resultant magnitude and direction (i know how to do this mathematically but programming is not working. the user should be able to select how many vector he/she wants (i don't know how to do this, so i added 3 vectors). here's my work - i did this purely algebraically. it's still incomplete but it compiles. my "if else" statement also doesn't respond correctly.
#include <iostream> #include <string> #include <vector> #define PI 3.14159 #include <math.h> std::vector<int> v; // declares a vector of integers using namespace std;
I'm working on a matrix class and I've hit a few snags. Here's what I've got so far:
Matrix.h
#include <iostream> #include <conio.h> using namespace std; class Matrix { private: int matrix[50][50];
[Code] ....
Where I have questions is in implementing the addition and subtraction bits into the class itself. I understand that I'm going to have to do a copy operation (this from reading in C++ Primer Plus 5th Edition). Right now I'm just after adding/subtracting as the rest will be variations on the same theme.
So, here it goes:
As I understand the problem, I need to pass my two matrices as arguments to an addition function. This is going to involve having to copy the values of the two existing matrices into temporary matrices within the addition function, then I'll add them, and store them in a new matrix which will be my return value. So...something like this:
int Matrix::matrixAdd(int R, int C, const Matrix & matrix1, const Matrix & matrix2) { int sum; Matrix matrix; for (int i = 0; i < R; i++)
[Code] ....
I do end up with errors there...C2240, and C2662. Again, I'm new to working through this, but that's what I've got. My idea is that I'm passing the maximum size of the array as defined by the user, in this case a 2x2 array, it'll cycle through and add up to that imposed limit...I went 2x2 because it's small enough that testing doesn't drive me up a wall.
Below is a code that is used to calculate complex numbers (a+bi, where i = sqroot (-1)) through multiplication and addition.
However, on my output file, no Header is being printed; the only thing that is being printed is "8 + 7i + = "
"complex.h" is included at the end of the code.
Code: // Trey Brumley// CMPS // Dr. Tina Johnson // March 1, 2013 // Program 2: Classes // This program will demonstrate the use of classes by using a custom "complex-number" (a+bi) class.
I'm writing an addition and subtraction calculator that takes input as: 5+6-3+2. You should be able to add or sub as many numbers as you want. I want the while loop to stop when the user hits enter. I put the getchar() function to catch the and break the loop but it is also swallowing the '-' sign, which I want to use to subtract and is instead adding the numbers with "sum+=number". How can I get around that?
Code:
#include <stdio.h> int main(int argc, char *argv[]){ int number, sum = 0;
I then overloaded the I/O operators so I could print to the screen information related Sales_data.
Code: // overload ostream in order for cout to work std::ostream& operator << (std::ostream & out, const Sales_data & cSales_data) { out << cSales_data.bookNo << ", " << cSales_data.units_sold << ", "
[Code] ....
My first issue is with overloading the addition operator. Everyone works correctly except for std::cout << item << std:endl; will no not output the ISBN number only the units_sold and revenue when added together.
After total = total + item;, I would like to print the total for this particular ISBN. However, I only get: blank, total units, total revenue where blank is where the ISBN would go but doesn't print after addition. My second question has to do with comparing the ISBN's of the books entered during the while loop. I would like to do something like
Code: if (item_i.bookNo == item_i+1.bookNo) { total = total + item; } else { std::cerr << "Books entered must have the same ISBNs" << std::endl; }
Unfortunately, I cannot figure out how to set up a comparison of the bookNos. If I used #include <casset> in the overload + rule, it will immediately exit since I have no way to compare the ISBNs.
I need to create a function that performs the addition of x days at a time, taking two integer values, the first being a date (yyyymmdd format) and a number of days to add / subtract that date.
How can I perform validation if the entire amount received is a valid date and how can I add x days of that date?
Below is a program that generates random Addition for Subtraction problems depending on the user's choice. The user is prompted to input an answer and then it keeps your score. If you want to quit you just press zero.
Code: #include <iostream> #include <stdio.h> #include <stdlib.h> #include <time.h> #include <iomanip> #include <string> using namespace std; int menu(); bool addition(int &reward); // function to return truth values
I am trying to code a program that takes in user inputted data about percentages and using it to later on calculate a final grade. 4 percents are inputted, for Assignments, Midterm1, Midterm2, and Finals. If the percents dont add up to 1 (i tell the user to enter the decimal value) I set up and if statement to catch it and end the program. Except that if i type in
I wanted to do this: Accept a line of input from user and save it to an array1 and copy its contents to other array in a set of arrays and then input another line to array1 and then copy it to next array in the same set and so on.... I know it is confusing but I can put it like that I want to create an array of arrays (Set of arrays). How can I do so?
I wrote a code to input the line in an array and tried to copy it another array of pointers, but pointers are just addresses so the same adress is copied again and again so, all the pointers of the array point to one address only. The code doesn't print anything when I try to print all the lines that were saved.
Code: #include <stdio.h> #include <stdlib.h>
#define MAXLEN 1000 #define MAXSIZE 100
int getline(char [], int ); void storage(char line[]);
I am trying to generate two arrays from one big array, of which the sum of the 2 array's elements are as close to equal or equal to each other if possible, or one array summed up minus the second array summed up will be as close to zero as possible. I start with int array of 30.
It says that the lowest possible combination of one array minus the other is 239 which I know is not true. Also this needs to run in under ten minutes.
#include <iostream> using namespace std; const int size = 30;
The first line indicates how many paths exist in my design. The second and third lines are those lines(the first number indicates 2 pairs, so 10,1 and 2,7 are 2 pairs) The first element in the third line indicates 3 pairs and the pairs are 8,3 and 7,7 and 10,7.
I have been able to read the text file and store these into ONE array. However, I need to divide them up and have each line in a seperate array.
So for example
array alpha to contain 10,1 and 2,7 array beta to contain 8,3 and 7,7, and 10,7
how to correctly use realloc on an array of char arrays? Say I want to store strings in arrays (=array of char arrays) and double the size of max. strings (y value):
Code:
int x=200; int y=10; char *carray[y]; for (int j = 0; j < y; ++j) carray [j] = malloc (sizeof(char)*x);} }
I have same question as posted by holla and Iam not sure about merging the contents of 2 sorted arrays into another array without duplication of values.
Place the even lucky numbers in an array called evenList, the odd lucky numbers in an array called oddList, and the negative lucky numbers in an array called negList.
//So in main main i passed the array as parameter and the size;
void lucknumberlist(int favnum[], int size) { int even = 0, odd = 0, neg = 0; int evenArray[even]; int oddArray[odd]; int negArray[neg]; if(favnum[even] % 2 == 0) { evenArray[even] = favnum[even];
I am puzzled with the strange behavior of my code below. The code has an apparent error but the results are correct. I am trying to put two arrays (chara and shuffled) into a third array join. The first 10 elements of 'join' should have the elements of 'chara' and the second half should have the elements of 'shuffled'.
You will note that in the second For loop, I am using 'chara' instead of 'shuffled' but when I print the contents of 'join' I am getting the correct numbers.
On the other hand if I replace 'chara' with 'shuffled' in the second For loop, I am getting incorrect results.
1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10,
Why is this happening? (I am using Codeblocks.)
#include <iostream> #include <stdio.h> using namespace std; int main() { int chara[]={1,2,3,4,5,6,7,8,9,10}; int shuffled[]={11,12,13,14,15,16,17,18,19,20};
I have a problem with my assignment. I would like to ask how to transfer positive and negative values from array temperature to arrays positive and negative?
#include <iostream> #include <iomanip> using namespace std; int main(){ int n=0, d=0, temperature[20], sum; int positive[], negative[]; float avg;
I'm working on a homework assignment that asks me to roll two die a user given number of times, find the roll sums, and a few other things. I'm working on it one module at a time and I'm running into two big problems so far.
The first problem is that my int variable rolls changes to a number within the random number generator range of numbers after I run rolldie. I got around this by making a const equal to the user entered value of rolls just so that I could continue developing the program.
My second problem is that the values of the arrays resultsOne[] and resultsTwo[] are changed after running findsum(). Why this is happening and I even tried passing them as const, but that changed nothing. We just started learning about passing arrays to functions, so there might be something big that I'm missing.
Code: #include <iostream> #include <cstdlib> using namespace std; void rolldie(int resultsOne[], int sizeOfresultsOne, int resultsTwo[], int sizeOfresultsTwo); void findsum(int resultsOne[], int sizeOfresultsOne, int resultsTwo[], int sizeOfresultsTwo, int tossSums[], int sizeOftossSums);