C++ :: Calculate Product Of 4 Vertical Values In Matrix

Jun 1, 2013

I am attempting to create a program which calculates the product of 4 vertical values in the matrix. The numbers are supposed to be randomly generated and the size of the matrix is given through the command window.

However I seem to have either not pointed my matrix through all of my functions correctly, or my logic is off somewhere as I keep getting this output regardless of the size of matrix I put in:

"the location of the highest horizontal line product is: 5 0 and is the number: 0

The overall max value is 4196352 at the above coordinates."

using namespace::std;
//srand(time(0));
int h_line(int**, int, int);
int v_line(int, int,int);
int diagnol_left(int,int,int);

[Code] .....

View 2 Replies


ADVERTISEMENT

C :: Calculate Product Of Two Matrices - Segmentation Fault In Program

Oct 29, 2014

New to C Programming, I have a problem with a little program I made that calculates the product of two matrices.

And here is the error I get:

View 4 Replies View Related

C/C++ :: Program To Calculate Inverse Of Matrix

Apr 3, 2014

I write this code for Inverse of matrix in C language . But there is error in determinant function that say "can not convert 'float' to 'float(*)[20]' for argument '1' to 'float determinant(float(*)[20])' " ....

/* a program to calculate inverse of matrix (n*n)*/
//actually one of the way to calculate inverse of matrix is : A^(-1) = 1/|A| * C(t)
that A is matrix and c(t) is taranahade A

#include <stdio.h>;
#include <conio.h>;
#include <string.h>;
#include <stdlib.h>;
const int max=20;
int i , j , n , k , size=0 , row , column ;
float num , det=0 , inverse_matrix[max][max] , matrix[max][max] , new_mat[max][max] , m_minor[max][max] , m_Transpose[max][max];

[Code] .....

View 14 Replies View Related

C++ :: Changing Values In A Matrix Using Void Function

Jun 29, 2013

I have the following void function devised to assign "+1" or "-1" to each element of a matrix at random. While the function does what I want, when I print the values of the matrix all are set to zero:

#include <vector>
#include "aRand.h"
#include <iostream>
void initConfig(std::vector<std::vector<int> > premat, int nL, int nN) {
int * pnRand;
pnRand = 0;

[Code]...

The function pnRand_plus returns a pointer to an array of random numbers from 1 to 100, with seed time(NULL) + i. The values printed in main are zero, despite the values printed during the function run are fine (-1s and +1s).

View 2 Replies View Related

C++ :: Array Matrix - Extract Values Which Does Not Repeat

Jul 27, 2013

I have an array matrix called tmat,,and i know that in every row of tmax there are values which repeat two times...and am writing a code to extract the values WHICH DOES NOT REPEAT into another matrix called tcopy...the codes compiles fine...and it writes nicely to file...but without the desired result...

One last question...how can i get the array tcopy written to file in the form 5x3...and not all the figures in line one after the other? i mean i wish to see the matrix like a matrix on file..not like a list of numbers....

Code:
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
const int R = 5;
const int C = 5;

[Code] ....

View 14 Replies View Related

C++ :: Create Matrix Of Data That Add Values Based On Reading Get From DVM

Apr 22, 2012

Ok I'm trying to create matrix of data that I can add values to based on a reading that I will get from a DVM. I'm using a 3d vector to do this. I need to keep track of the serial number, the day and within day I need to take two readings at different temps, this will continue for 7 days.

The rows of my 3d vector will be the days, the colums will be the serial numbers the depth will be the reading at the different temps.

What I need to do is compare the first element (days) and when it is greater then or equal to 4 I will perform calculations of the readings. So all I want to do is compare the first element of the vector, How do I do this?

Here is what I got

Code:
#include <vector>
typedef std::vector<double> Double1D;
typedef std::vector<Double1D> Double2D;
typedef std::vector<Double2D> Double3D;
#define HEIGHT 5
#define WIDTH 3

[Code]....

View 7 Replies View Related

C :: How To Calculate Range Of Values

Nov 23, 2013

What the range of values ​​and how to calculate them?

int Num = rand() % 350 + 13 / 10

View 2 Replies View Related

C++ :: Calculate The Size Of Values?

Dec 16, 2013

I'm trying to calculate the size of values I've dynamically allocated memory to, i.e.

col_ind = new long[nz];
row_ptr = new long[inrows+1];
val = new double[nz];

from pointers. Now I've created the function,

int getmemsize(int i) {
int sizes[3];
sizes[0] = sizeof val;
sizes[1] = sizeof col_ind;
sizes[2] = sizeof row_ptr;
return sizes[i];
}

but each one is returning just the value 4? My arrays (one example) look like:

val = [ 5 2 5 9 8 3 9 10 9 ]
col_ind = [ 0 1 1 ]
row_ptr = [ 0 2 3 ]

View 6 Replies View Related

C/C++ :: Calculate Sum For Input Values Of X And N

Feb 27, 2015

I added my assignment to attachment, i need to calculate the sum for input values of x and n this is my code:

#include<stdio.h>
#include<math.h>
main() {
float gore,dole,s,x;
int n,i,j,z;
s=0;
i=0;
j=0;

[Code] ....

gore calculates x^(2*i)-3 and dole is for (2+i)! for input x=1 and n=1 i get -2.0 output which is the value of x^(2*i)-3 the (2+i)! part gets ignored for some reason, for any other input i tried the output is 0 ....

View 6 Replies View Related

C++ :: Calculate Average From Array Values

Jan 8, 2014

i wrote following code to calculate average of the values entered to the array.After displaying the output following error was displayed.

"Run-Time Check Failure #2 - Stack around the variable 'marks' was corrupted.

A buffer overrun has occurred in q 3 410005111.exe which has corrupted the program's internal state. Press Break to debug the program or Continue to terminate the program. "

//Average mark of student 1
cout<<"Avarage mark of the student 1 :"<<(marks[0][0]+marks[1][0]+marks[2][0]+marks[3][0]);
cout<<endl;

View 5 Replies View Related

C++ :: Find Eigen Values Of Any Given Matrix Of Dimension NxN - Access Violation Writing Location 0x

Jun 4, 2012

I am really desperate on trying to make my code work. The code is to find the eigen values of any given matrix of dimension NxN. The input can be the diagonal of any NxN matrix alongwith its subdiagonal. The code works fine for N~350 or so but when i go beyond that these errors appear.

First-chance exception at 0x00425ea4 in divide.exe: 0xC0000005: Access violation writing location 0x01141000.
Unhandled exception at 0x00425ea4 in divide.exe: 0xC0000005: Access violation writing location 0x01141000.

But as i have never declared any variable statically and when i dynamically allocating memory with variables it should work like it does for smaller N values.

View 14 Replies View Related

C :: Calculate Number Of Distinct Values Entered Into Array

Sep 12, 2013

I'm trying to calculate the number of distinct values entered into an array. If i enter the followings "3,4,5,6,7,7,6,e (anything that's not a number)" . I get a total of 7 but in reality it should be a 5.

Code:

#include <stdio.h>
//---------function to find the distinct values----
int find_distinct(int list[], int size)
{
int i, j,size2, distinct = 0;
for(i = 0; i < size; i++)

[Code]...

View 9 Replies View Related

C/C++ :: Calculate Total Cost Given The Tax Values - Getting C2784 Error

Sep 3, 2014

// Purpose: calculate total cost given the tax values

#include <iostream>
#incluse <string>
using namespace std;
int main() {
double purchasePrice, stateTaxAmt, countyTaxAmt, totalCost;
//Display purchase price

[Code] ....

View 2 Replies View Related

C++ :: Using A For Loop To Input And Output Array Values Also Calculate The Average

Jan 24, 2014

I have this code that im stuck on what i need to do is Extend the code such that when it starts the user is asked to input values to specify each of the three ranges before moving on to accept and tally the main values how do i do that Using a for loop to input and output array values Also calculate the average

*/
#include <stdio.h>
int main(void)
{
/* Declare an array of integers */
int Grades[5];
int nCount;
int nTotal = 0; /* Declare and initialise the value */
float fAverage;

[Code]...

View 1 Replies View Related

C/C++ :: Calculate Volume Of A Cone With Values For Diameter Of Base And Height

Jan 30, 2014

I am having trouble with calculating the volume of a cone

Assignment: Using the knowledge you already have, create, build, run, and correct if necessary a program that will calculate the volume of a cone. Insert into your code values for diameter of the base and the height. Use variables, constants, literals, and mathematics as necessary.

The formula for the volume is:

1/3 π x Radius2 x Height

Hint: you will need to add to your program two lines where appropriate:

#include <cmath>
const double PI = 2*acos(0.0);

Here is my current code:

#include <iostream>
using namespace std;
int main () {
//diameter of the base
float diameter = 3;

[Code] ....

View 3 Replies View Related

C++ :: User Input - Calculate Sum Of Only Positive Values While Ignoring Negative Numbers

Jun 19, 2014

So I have to make a program that allows the user to enter both positive and negative numbers and the program is suppose to calculate the sum of only the positive values while ignoring the negative values. Also it is to be a sentinel-controlled loop with a number ending the set of values.

View 4 Replies View Related

C++ :: How To Get The Cross Product

Oct 10, 2014

I am trying to compute the cross product of an 1x6 column vector "D" with a 6xN matrix "S".

vector< vector<float> > D(1, vector<float>(6));
vector< vector<float> > S(6, vector<float>(10)); // Example where N = 10
float cProduct = D*S; // ?

The last line fails, so I'm wondering how you would get the cross product?

View 2 Replies View Related

C :: Scaling Y Axis - Vertical Histogram

Mar 6, 2015

Scaling the yaxis on my histogram for one of my class projects. I've gotten mostly everything but stuck on scaling. I'm pretty sure it's something simple to do, but I'm having trouble, and I've tried everything to my knowledge to get it scaled from 0.1 - 1, like this:

Here is my code:

#include<stdio.h> //include all preprocessor directives
#include<Windows.h>
int main(void) {
int MAX = 0; //initialize and declare variables
int allcounts [10] = {0}; //store an array of integers for
int yaxis, xaxis = 0;

[Code] ....

I'm close, but every time I try and change my y axis in the for loop from 1 going down to 0.1, it doesn't give me a right output.

View 2 Replies View Related

C++ :: Find Vertical Paths Of Length

Jul 24, 2014

I'm trying to find vertical paths of length n through a 2D grid of numbers. Paths may connect orthogonally or diagonally. An example grid and an example possible path looks like this:

//Grid
0 1 2 3 4 5 6 7

0 2 4 6 4 1 3 4 5
1 5 3 5 8 6 6 6 6
2 3 4 2 1 1 2 5 3
3 3 2 3 3 1 3 4 5
4 3 6 1 1 5 2 5 4
5 2 5 4 2 4 5 6 2
6 6 6 1 1 5 1 4 5
7 1 5 6 4 2 4 2 3

A example possible path of length n = 3 is running from (3,2) to (3,4) - All 1s ...An example of n = 4 is the run of 3s (1,1) (0,2) (0,3), (0,4)

What is an efficient algorithm for solving this kind of problem? I would like to solve (ideally) millions of grids, giving a list for each grid of all possible paths of length for n = 3-6.

View 11 Replies View Related

Visual C++ :: Vertical Spacing On CMenu

Sep 20, 2012

I have an MDI MFC application which has a menu at the top. Nothing particularly unusual about that, but for some reason my application seems to have a vertical spacing about 30%-40% bigger than "normal" on the drop down menus (when compared with Visual Studio itself).

I've looked thru the options for CMenu, CMFCMenuBar, CMFCVisualManager, but can't seem to find anything to explain why my menu has such a large vertical spacing between options, nor how to change it.

View 4 Replies View Related

C++ :: For Loop To Sum Up Product Of Several Arrays

Feb 2, 2013

I need a for loop that sums up the product of several arrays.

int total = 0;
for (int i=0; index < (columns - 2); index++)
for(int indexFF = 0; indexFF < CG[index + 2] - 1; index++)
for (int indexIN = 0; indexIN < CG[index + 1] - 1; indexIN++, total++)
NRN[CG[index + 1]+indexFF] += FF[total] * NRN[indexIN + CG[index]];

right now "columns" is set to 3

CG[] is an array of 10 integers for "column groups"

for now they are set to:

CG[0] = 0
CG[1] = 3
CG[2] = 4
CG[3] = 3

NRN[] is an array of floating points
NRN uses CG to map its indexes out

0 3 7
1 4 8
2 5 9
_6

FF[] is an array of random numbers basically constants

I need the for loops to sum:

NRN[0] = 0.5
NRN[1] = 0.75
NRN[2] = -1
NRN[3] = NRN[0]*FF[0] + NRN[1]*FF[1] + NRN[2]*FF[2]
NRN[4] = NRN[0]*FF[3] + NRN[1]*FF[4] + NRN[2]*FF[5]
NRN[5] = NRN[0]*FF[6] + NRN[1]*FF[7] + NRN[2]*FF[8]
NRN[6] = -1
NRN[7] = NRN[3]*FF[9] + NRN[4]*FF[10] + NRN[5]*FF[11] + NRN[6]*FF[12]
NRN[8] = NRN[3]*FF[13] + NRN[4]*FF[14] + NRN[5]*FF[16] + NRN[6]*FF[17]
NRN[9] = -1

NRN, FF and CG are the only things in other code that I can't change in the loops

when I debug it index goes to 3 and overflows its memory. which it shouldn't because columns = 3 so "index < (columns - 2)" should stop at 1

View 2 Replies View Related

C++ :: Calculating Vertical Position Of Scroll Bar For A List Box?

Aug 16, 2013

im trying to code a simple list box for my self made GUI but i seem to be stuck at the scroll bar. I already finished with the calculation for the scroll bar size but how I could calculate it's current vertical position depending on the current item on top of the list box.

My current code looks like this

ListBox struct:
struct MenuListBox {
int PosX;
int PosY;
int Width;
int ItemsVisible; //Items visible at the same time
int CurrentItem;

[code]....

Additional vars in the menu class:

MenuListBox* MenuListBoxes;
int ListBoxCount;

How could i calculate this:

New->CurrentScrollBarPosY = ; ?

View 15 Replies View Related

C++ :: Enter Name Then Output Name In Vertical Position Using For Loop

Feb 21, 2013

How to fix this when i run the program and enter my name then output my name in vertical position using the for loop and press enter the program do not stop

#include<stdio.h>
#include<conio.h>
#include<dos.h>
main() {
char name,n;
clrscr();
printf("Enter Your Name:");
scanf("%c",&name);

[Code] ....

View 3 Replies View Related

Visual C++ :: Vertical Size / Height Of Control Bar In MDI App?

Jan 28, 2014

In a MDI-app with some toolbars and statusbar I created also a controlbar which can be docked to the left side. My problem now: how do I get the exact height of the controlbar?

In CalcDynamicLayout I set the height for the docked state to the height of the mainframe. This value is too big, but it will work basically.

But how can I get the exact height of the controlbar?

View 4 Replies View Related

C :: Creating Product Inventory File?

Jan 26, 2013

How to make a program in C to create a product inventory file containing pro0duct name, cost and quantity and then read the prouct inventory file.

View 9 Replies View Related

C++ :: Program That Prints A Discounted Product

Sep 29, 2014

So I need to make a program that reads distance and number of days of a person that is buying a ticket. If distance is greater than 1,000 kilometers AND the person stays more than 7 days, the discount is 30% of the ticket. The cost per kilometer is $1300. Print the ticket with discount.

I used variable distance as float because it will be multiplied with 0.3 for the discount... not sure if I'm right on that.

Code:
#include <iostream>
#include <conio.h>
using namespace std;
int main() {
float distance;
int days;

[Code] .....

I tried another way but haven't done it in code...

ask for distance
ask for days

Ticket= (Dist x 2 x $1300)
If (dist>1000) && (days>7)

cout<<Ticket=Ticket * 0.3;
else { cout<<Ticket;

View 2 Replies View Related







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