C++ :: Compute Area Of A Triangle Using Cross Product

Jan 8, 2015

I have to write some cpp program which computes area of a triangle using cross product,we give 3 vertices as R2 and 3 edges as double.

I am beginning like this;

#include <iostream>
#include "R2.h"
#include <cmath>
using namespace std;
double area ( R2 *A,double *z)

[Code] .....

View 5 Replies


ADVERTISEMENT

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++ :: How To Compute Perimeter Of A Triangle

Jun 26, 2013

I intended to compute perimeter of a triangle. The problem is the initial value for the triangle.

#include <iostream>
#include <cmath>
using namespace std;

struct Point{
double x;
double y;

[Code] ......

I expect to get 0 for triangle1, but I get some strange value...

Here is the result

Type x for point1 : 1
Type y for point1 : 1
Type x for point2 : 3
Type y for point2 : 1
Type x for point3 : 1
Type y for point3 : 3
The perimeter of the triangle1 is : 2.82843
The perimeter of the triangle2 is : 6.82843

View 2 Replies View Related

C/C++ :: Area Of Triangle Calculator?

Nov 16, 2014

I was asked to build a small program to calculate the are of a Triangle but my code must have some problem.. />

#include "stdafx.h"
void main()
{
int a,b;

[Code]....

I get this errors:

-warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS.

-warning C4244: '=' : conversion from 'int' to 'float', possible loss of data

View 4 Replies View Related

C :: Calculates Area Of A Triangle - If Statement

Jun 10, 2013

I am currently learning "if statements" while doing a program that calculates the area of a triangle. My problem is that the result is always "0". I am pretty sure the problem lies within my math, but how I have set it up wrong.

I am using Heron's Formula. Here it is for reference:

area=sqrt(s(s-a)(s-b)(s-c)) where s=(a+b+c)/2

Code:
#include <stdio.h>
#include <math.h>
int main () {

float area, sideA, sideB, sideC, halfP;

[Code] ....

View 4 Replies View Related

C++ :: Program To Find Area Of Triangle?

May 26, 2013

i have written a program to find area of triangle, but i meet some errors,

//******area of triangle******//
#include<iostream>
using namespace std;

[Code].....

View 1 Replies View Related

C++ :: Calculating Area Of A Triangle Using Heron Formula

Nov 7, 2014

I need to calculate the area of a triangle using heron's formula. I wrote the code below and i need to modify it so that a user is required to keep entering the three side until he/she decides to stop. If the three sides entered make an invalid triangle, the user is required to re-enter the values until valid triangle is formed. Then the area is displayed.

#include <iostream>
#include <cmath>
using namespace std;
int main(){
double a,b,c=0;
double s,A=0;

[Code] .....

the screen output should like this:

Enter three sides of a triangle: 0 1 2 Error!
Re-enter three sides of a triangle: -1 1 2 Error!
Re-enter three sides of a triangle: 3 4 5 => 6

Continue (y/n)? y

Enter three sides of a triangle: 1 1 2 Error!
Re-enter three sides of a triangle: 6 8 10 => 24

Continue (y/n)? n

Done!

Please note that Continue (y/n)? only displayed after a valid triangle is formed. Otherwise, the user needs to re-enter sides until it's valid.

View 1 Replies View Related

C/C++ :: Find Triangle In Array Of N Triangles Which Has Largest Area

Apr 6, 2015

How to find triangle in an array of n triangles which has the largest area?

#include <stdio.h>
#include <stdlib.h>
#include<math.h>
typedef struct {
double x,y;

[Code] .....

View 14 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 :: 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

C++ :: Kronecker (direct) Vector Product

Feb 19, 2013

How to code the Kronecker/direct product of two vectors??

The direct product of the vectors a and b is given as the matrix below (note "x" refers to x with a circle around it and is the symbol for a Kronecker product):

(a1, a2,..., an) "x" (b1, b2,...,bn) = [a1b1, a1b2,..., a1bn]
[a2b1, a2b2,..., a2bn]
[ . . . . ]
[ . . . . ]
[ . . . . ]
[anb1, anb2,..., anbn]

The way I have coded the rest of the program is such that the matrix shown here is represented by a vector of length equivalent to the number of elements in the matrix. So I want the Kronecker product to give me a vector of length n^2 (where n is the number of elements in each initial vector).

View 3 Replies View Related

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 View Related

C++ :: Array Of Structures - Storing Product Information

Nov 5, 2013

I have been dealing with this problem for quite some time, I've been assigned to develop a program that can store products' information within structures (the number of products is undefined). I thought I should use an array of structures, but I don't know how to declare it properly. This is what I thought would work:

struct product {
string name;
string in_stock;
float sale_cost;
int id; }
prod [n]; //n being the undefined number of products the user will register/delete/modify

I already saw an example of array of structures, but it uses a defined number.

View 13 Replies View Related

C++ ::  sorting Ascending Order By According To Product Id / Name / Price

Jul 20, 2014

Here is my code below:

#include<fstream>
#include<iostream>
#include<stdlib.h>
#include<iomanip>
#include<string>
using namespace std;
void main() {
fstream file;
string id,name,type,price;

[code].....

I can't separate and align 4 categories neatly, how to do this solution below(the link of example for sorting Product ID in ascending order): [URL]

By the way,here is the required .txt file(test.txt): [URL]

View 4 Replies View Related

C :: Best Process For Cross Compiling Application

Oct 26, 2013

I'm creating a small command line game in C. I have never done anything cross platforms, but this is small enough (so far) that it might not be too bad.

When I am done, I'm not sure how it will be distributed: Either I will just send people the C files and say "compile on your system with these options", or I will just have executables for various systems. Probably Windows 7/8, Ubuntu, CentOS, and whatever I can find to test on.

I right now I'm testing/developing on Windows 7 using MinGW. So my questions are: while I'm developing, how should I be compiling/testing it?

View 4 Replies View Related

C++ :: Write Cross-platform File IO

Aug 21, 2013

I discussed a topic about how to write cross-platform file IO code with a member named Disch for about a year ago. Since I am a beginner I am not sure if the "rules" for doing this has changed or not within C++.

He taught me that differenct CPU:s use different endianness when reading and writing to files. However, why can't the C++ standard file IO functions detect what endianness should be used on the current machine that is running the program? Why didn't the developers who created the standard library develop file IO functions that are cross-platform from the beginning? Have the rules changed since last year?

What I learn is that if you need to store data in files that will be read and written to on different machines, you have to define in the program what endianness should be used. For example, if I needed to store 4 bytes, I had to do this manually with my own functions and define in those which endianness is used.

View 3 Replies View Related

C++ :: Cross Platform Way To Execute A Program?

Apr 18, 2014

System();is bad, I get that. Is there another way, that works across platforms I can use to execute an external program. If not, is there a windows specific way.

View 2 Replies View Related

C# :: API That Convert 2D Cross Sections Into 3D Shape

Mar 1, 2014

I have cross sections in the form of rectangles in the XY plane formed from two point (top left, bottom right) as well as their Z position. I'd like finding some sort of API that can extrude a basic linear-average-approximated 3D shape (preferably eventually into STL format) from these points. I've tried googling but to no avail. The aim is to build a 3D shape from 2D wireframes.

View 2 Replies View Related

Visual C++ :: Cross Platform GUI Development

Aug 28, 2013

I am planning to develop a GUI that will run on Windows, Linux, Android & iOS. If am right, VC++ apps don't work on Linux, Android & iOS. Is that correct?

Is there an alternative to that? Which other tool works for GUI development on above mentioned 4 platforms?

View 2 Replies View Related

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 :: Boolean Value Cross-functional In Game TicTacToe

Dec 11, 2014

Why something doesn't work without setting global variables. I want to know how to deliver values for example my boolean value "ende" (means end) from the function in line 99

Code:
bool pruefeGewinn() or in line 116 Code: bool spielfeldVoll() to the main function for using it there for Code: } while (ende != true); in line 164.

How to return it correctly?

Here is the Code of the game TicTacToe.

Code:
#include <stdio.h> // In- and Output
#include <stdlib.h> // Implementation of many functions
#include <stdbool.h> // Allows in C99 True and False as Boolean
#include <time.h> // Allows using Random by time

/*----------------------- Constants -------------------------*/

#define KANTENLAENGE 3
#define STRING 100

[Code] .....

View 6 Replies View Related

C++ :: Cross Platform Library For Simple Dialogues

Oct 17, 2013

In my game, I want to display dialogues for exceptions, and I don't really want to use something heavy like Qt, but then I also don't want to write and maintain my own platform-specific code to do it. Is there any library that can display simple message dialogues, just a few lines of text and an OK button, without being complete overkill like a full-blown GUI library?

View 13 Replies View Related

C++ :: Checking Dynamic Memory Cross-platform?

Feb 10, 2014

Suppose:

cin >> number;
pointer = new type[number + (rand()%number);

So, I wont know the memory allocated for pointer. How can I check it in all OS?

View 4 Replies View Related

C/C++ :: How To Cross Compile A GTKmm (Hello World) Program

Jun 20, 2014

I'm using ubuntu 14.04 and I want to cross compile this simple GTKmm program for Windows:

#include <gtkmm.h>
int main(int argc, char *argv[])
{
Glib::RefPtr<Gtk::Application> app =
Gtk::Application::create(argc, argv,
"org.gtkmm.examples.base");
Gtk::ApplicationWindow window;
return app->run(window);
}

I don't know how to do this...When I use this command:

x86_64-w64-mingw32-g++ main.cpp -o hello.exe `x86_64-w64-mingw32-pkg-config gtkmm-3.0 --cflags --libs`

I get this error:

In file included from /usr/include/cairomm-1.0/cairomm/fontoptions.h:26:0,
from /usr/include/cairomm-1.0/cairomm/surface.h:37,
from /usr/include/gdkmm-3.0/gdkmm/pixbuf.h:40,
from /usr/include/gdkmm-3.0/gdkmm/dragcontext.h:31,
from /usr/include/gtkmm-3.0/gtkmm.h:90,
from main.cpp:1:
/usr/include/cairo/cairo-ft.h:50:35: fatal error: fontconfig/fontconfig.h: No such file or directory
#include <fontconfig/fontconfig.h>

[code]....

View 10 Replies View Related

C Sharp :: Retrieving USB Pendrive Vendor ID / Product ID And Serial Number

Sep 15, 2012

I am trying to retrieve the parameters from externally connected pendrive. I have been using WMI to achieve this but not able to separate the pendrive's parameters from the other USB devices (such as USBcamera,USBHub etc) ....

View 2 Replies View Related







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