C++ :: Increasing Integers Automatically Within Two Dimensional Array
Nov 15, 2013
I am new to programming all together but i have been writing a program in c++ and im coming up against an issue with my array.
#include<iostream>
#include<iomanip>
#include<string>
using namespace
int main () {
int a ;
int b ;
char answer ('Y') ;
[Code] ....
I am trying to get the program to increase say year one by 1 when the condition is met i have tried
if ( a >= 70 && a <= 100 && b == 1)
{grade [0][0] = 0 + 1;}
and
for (grade[0][0] = 0 ; a >= 70 && a <= 100 && b == 1 ; grade [0][0]++)
{grade [0][0]= 0 + 1 ;}
Now all that i want is that the array will take the information from int a and int b and then add 1 to the appropriate part of the array . I have tried putting it in deferent places but its not working for ether. the program will run but it will not add to the array.
View 13 Replies
ADVERTISEMENT
Feb 13, 2015
display the 3rd element of a two dimensional array of integers named T of size 2x5?? i don't know how to start because i'm just advance studying with array
View 4 Replies
View Related
Feb 3, 2014
How will you code a program that displays the maximum value in a two dimensional array of integers. the program will ask the user to input the 4x5 array?
i know how to code it. but i dont know what to do to find the maximum value. :( how to find the maximum?
View 4 Replies
View Related
Jan 8, 2015
Using two-dimensional arrays, write a program which multiplies an mxn matrix of integers by an nxr
matrix of integers.
INPUT FIRST (2x2) MATRIX:
Type in 2 values for row 1 separated by spaces: 3 4
Type in 2 values for row 2 separated by spaces: 5 7
INPUT SECOND (2x2) MATRIX:
Type in 2 values for row 1 separated by spaces: 1 1
Type in 2 values for row 2 separated by spaces: 2 2
3 4
5 7
TIMES
1 1
2 2
EQUALS
11 11
19 19
View 1 Replies
View Related
May 2, 2014
class Album{
private:
char albumName[100];
Song* List;
int numSongs;
public:
Album(char*);
~Album();
[Code] ....
And everytime I create the class it can have only one song because I set numSongs to zero.
View 2 Replies
View Related
Jun 1, 2014
I am trying to make a double array, but I keep getting an error Segmentation fault (core dumped) when I make more than 105 elements in the array. I need to make 114 elements.
I am building my array with myarray[999] and increasing the number doesn't seem to do anything.
How can I store more elements in my array?
View 1 Replies
View Related
Nov 7, 2014
I am working on a number of utility functions for two dimensional arrays of integers, or matrices. However I am having a problem with segmentation faults, most likely due to errors in using malloc in functions like copyMatrix.
Code:
matrix_utils.h~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//This function checks if two matrices are equal
int isEqual(int **A, int **B, int n);
//This function returns one row of a matrix
int * getRow(int **A, int i, int n);
//This function returns one column of a matrix
int * getCol(int **A, int j, int n);
[Code] ....
View 2 Replies
View Related
Jul 31, 2013
How can I concatenate two 2-dimensional int arrays into one larger 3-dimensional array. This question is also valid for the 3-dimensional vectors. I know the command for the one dimensional vector as:
std::vector<int> results;
results.reserve(arr1.size() + arr2.size());
results.insert(results.end(), arr1.begin(), arr1.end());
results.insert(results.end(), arr2.begin(), arr2.end());
and for the one dimensional array as:
int * result = new int[size1 + size2];
copy(arr1, arr1 + size1, result);
copy(arr2, arr2 + size2, result + size1);
But I do not know how to make a 3-dimensional array or vector.
View 3 Replies
View Related
Jul 30, 2014
In pseudocode and in C code, declare two 1-dimensional parallel arrays of Integers to store the age and weight of a group of people that will hold the information of up to 10 people. Use a For loop to iterate through the array and input the values. This is the code i have, but my array is showing up as 11 and not 10?
Code:
#include <stdio.h>
int main() {
//Define Variables
float Age_Data[10],Weight_Data[10];
float Age_Input,Weight_Input;
[Code] .....
View 3 Replies
View Related
Dec 9, 2014
I am trying to execute a very simple piece of code. But I am unable to find how the value of T[i][j] is changing all of a sudden. CODE:-
insert Code:
void initialize(float** &T,int NP,int D,int low,int high) {
int i = 0,j = 0;
T = (float **)malloc(NP*sizeof(float));
for(i = 0;i<NP;i++)
[code].......
View 2 Replies
View Related
Jan 17, 2014
I had a hard question in my C++ final exam and I'm trying to solve it for the last 3 days. I haven't succeded yet! Here is the question: You have a one-dimensional array A[20]={1,2,3,4,...,20} and B[5][4] you have to assign the A array's elements to the B array but there is an order which is: B[5][4] = { { 12, 9, 11, 10 }, { 14, 7, 13, 8 }, { 16, 5, 15, 6 }, { 18, 3, 17, 4 }, { 20, 1, 19, 2 } } and there is a restriction: you can only use ONE for statement, nothing else!
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
int A[20] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20 }; // define A array's elements.
int B[5][4] = { 0 }, k = 1; // define B array and k counter.
[code]....
I can't narrow the statements to one,This program works perfectly but it shouldn't be that long, we need ONLY ONE FOR statement, not two!
View 2 Replies
View Related
Mar 19, 2014
is it allowed to to like this:
char a[10] = "Lizard";
char b[2][5];
b[0][0] = a[0];
b[0][1] = a[1]; etc?
View 1 Replies
View Related
Sep 2, 2013
I have a 3D array that contains 200 strings. I'm trying to copy all these strings into a 2D array. How can this be done? This is what I have so far but it isn't working correctly.
Code:
for(int i = 0; i < row; i++) {
for (int j = 0; j < col; j++)
{
dest[i][j] = source[0][i][j];
} }
The finished product would be with 100 rows, 2 columns.
View 4 Replies
View Related
Aug 30, 2013
convert an one dimensional array into a two dimensional array and print like a matrix.
input: 34 50 2 4 90 33 7 80 9
output: A is a 3x3 matrix
34 50 2
4 90 33
7 80 9
View 12 Replies
View Related
Jan 10, 2015
Write a program using user-defined function which accepts an integer array and its size as arguments and assign the elements into a two dimensional array of integers in the following format: If the array is 1,2,3,4,5,6, the resultant 2D array is
1 2 3 4 5 6
1 2 3 4 5 0
1 2 3 4 0 0
1 2 3 0 0 0
1 2 0 0 0 0
1 0 0 0 0 0
View 1 Replies
View Related
Oct 10, 2014
Im having trouble on getting the quantity up of the variable "item.iqty". For example the current quantity is 5 and in this function, the user inputs a number and it should add to the variable "item.iqty". So if if the user inputs 2 then the current quantity should be 7 now but in my program it hasnt changed. its still 5
void addQty(FILE *fp)
{
int num, qty, r, c, n;
bool found;
[Code]....
View 3 Replies
View Related
Sep 5, 2014
I'm trying to implement a linked list using my own node class. I've created functions to add to the head and tail, return the size of the linked list as well as the value stored within the current pointer.
However, my problem is that when I wrote a test program to see whether my list worked, my list did not appear to increase in size past 1 item in the list.
this is the test program I wrote:
int main() {
int counter,
data;
linkedlist *my_list = new linkedlist();
cout << my_list->size() << endl;
for (counter = 0; counter < 5; counter++) {
[Code] ....
I'm sure it's probably something simple that I've overlooked . But I'm still relatively new to the concept of dynamic memory allocation.
View 2 Replies
View Related
Dec 6, 2014
Code:
#include <iostream>
using namespace std;
int j;
int n;
int recursive ( int arr[j] );
int main() {
int i;
int arr[10000];
[code]....
This is how I tried making the program..
I want it with a recursive function
I want if the sequence is non decreasing return true else return false
View 10 Replies
View Related
Apr 23, 2012
We have socket server which is developed in c# .net 3.5.
I see server memory keep on increasing whenver client disconnectes and connects.The server disconnects client if client didn;t send valid credentials.
When client is trying to connect with invalid credentials the memory is keep on increasing.
Here is the code that handles disconnection.
try {
if (state.workSocket != null) {
log.DebugFormat("ssl socket displose,{0},{1}", Doomed, IP);
state.workSocket.Shutdown(SocketShutdown.Both);
state.workSocket.Close(1);
state.workSocket = null;
log.DebugFormat("ssl socket displose complete,{0},{1}", Doomed, IP);
[Code] ....
View 7 Replies
View Related
Apr 20, 2013
I was able to get the max to work but I cant get the min. it returnning something like -125863456.
Code:
int maxx(int a[][10]);
int minn(int a[][10]);
int main(void){
int array[][10] = { { 2, 7, 6, 8, 4}, {3, 9, 1, 5, 6} };
int max1, min1;
[Code] .....
View 3 Replies
View Related
Oct 25, 2013
I want to make a program that asks the user for a message and then print out a large graphic of that message. For example, if the user types "he" I want to print out
H..................H EEEEEEEEE
H..................H E
H..................H E
H..................H E
HHHHHHHHHH EEEEEEEEE
H..................H E
H..................H E
H..................H E
H..................H EEEEEEEEE
(treat the periods as spaces. I only put them there because it wouldn't separate the H's correctly.)
I will loop this to continue until the user types quit.
1. How would I set this up to store the user input characters into an array?
2. How would I print out the stored data in the shape of the word?
View 4 Replies
View Related
Dec 19, 2014
Is it possible to create an 8 dimensional array in C? If no, then what can I do to improvise or let say bypass the limit?
View 7 Replies
View Related
Oct 21, 2014
Consider the following code snippet:
GLfloat box[4][4] = {
{ x2, -y2, 0, 0 },
{ x2 + w, -y2, 1, 0 },
{ x2, -y2 - h, 0, 1 },
{ x2 + w, -y2 - h, 1, 1 },
};
Do I need to call a variant of
delete [] box;
Against this float array?
View 1 Replies
View Related
Apr 1, 2013
int sum(int (*ar2)[4], int size);
// I dont know what the ar2 is going on
int main(){
int data[3][4] = {{1,2,3,4},{5,6,7,8},{9,10,11,12}};
int total = sum(data, 3)
return 0;
}
View 4 Replies
View Related
Jan 9, 2014
Here is what I have, I have a 1D Array being added to a 2D Array and I need to Sort them by value value 3 in the 2D Array, while maintaining a specific amount. Here is what I have so far:
public static void CheckHS(string[] HS) {
try {
GeneralData.HighScores[10, 0] = "11";
GeneralData.HighScores[10, 1] = HS[1];
GeneralData.HighScores[10, 2] = HS[2];
GeneralData.HighScores[10, 3] = HS[3];
//Need Sort Data - Bubble Sort?
}//end Try
catch (Exception ex) { MessageBox.Show(ex.Message); }
}
I am thinking bubble sorting but I remember reading about something faster. Unfortunately I can't find it on the web. The idea is that there will be always 10 Values and 4 Columns on the 2D Array. [The 11th Row being empty at the end of it.
View 14 Replies
View Related
Apr 24, 2013
I want to create 4 dimensional array, in that first three dimenstional are fixed size and the final index will be on 0 to N-numbers.
E.g., double array[500][25][10][<NOT FIXED>].. So I cant create statically, because the index size are more. Also I have tried 4 dimenstional vector, but its giving 2 problem.
(i) I am storing 4th dimenstion size is more than vector[0][0][0].max_size()
(ii) Storing and Retrieving its more time in vector
So, any other solution to store large array which is 3 index is FIXED and final one is not FIXED?
View 16 Replies
View Related