C :: Working With Equations

Nov 19, 2013

I need to find out all the possible equations which are same of a given equation. For eg. a+b+c-d and b+c+a-d are same. So if the user inputs a+b+c-d then the output will be all the possible equations that can be formed from the given equation, viz:

a+c+b-d
c+a+b-d
-d+a+c+b

etc

i.e the program should rearrange the operands and operators in such a way that it should give the same result.

View 5 Replies


ADVERTISEMENT

C++ :: Equations And Intersection Point

Aug 17, 2013

Program which accepts two lines and and determines their intersection point and whether they lie within a circle, also given interactively. I'm racing against time and I've racked my skull to no avail

View 2 Replies View Related

C :: Calculate The Solutions Of Quadratic Equations

Oct 22, 2014

I have a task to find errors in this long line of code in order to correctly calculate the solutions of quadratic equations.

Code:
int main(int argc, char *argv[]) {
int validInput, solution_type;
double a, b, c, root_1, root_2, q;

/***********************
* Input / Validation
***********************/

/* Check numbers of arguments, and read input */
validInput = (argc = 4);

[Code] ....

Is a section of the code (the first section). And as you can probably guess, it goes on to calculate for a > 0 etc...

I dont really understand what the validinput section is saying? And a, b and c are never defined so Xcode is just saying a,b,c,root1,root2 are uninitialized and I also dont know what means. Do I need to define these values?

Code:
int main(int argc, char *argv[]) {
int validInput, solution_type;
double a, b, c, root_1, root_2, q;

[Code] ......

View 9 Replies View Related

C :: Calculate Equations Just Like A Standard Calculator

Oct 23, 2013

The main point of the program is to calculate equations just like a standard calculator but I wanted to do it myself. I don't understand what the problem is right now but I've managed to create a program that asks for both values but somehow it doesn't want to ask for an operator (*, /, + etc). What's wrong with my code that the terminal skips the scanning part for the operator?

Code:

#include <stdio.h>
int main() {
int value1, value2, answer;
char operator;

[code]....

View 12 Replies View Related

C :: Program That Solves Math Equations

Apr 30, 2013

I wrote a program that solves an equation of two numbers, but in addition to that, I want it to be able to continue to solve longer equations. Ex: ( solves 2 * 4, or 2 * 4 - 5).I want to put this part of the program's result into a variable and go from there. How do I place the result of the calculation into a variable, and where would it go?

Code:

#include <stdio.h>
#include <string.h>
int main(void) {
int a;
scanf("%d", &a);
char s[2];
scanf("%s", s);
int b;
scanf("%d", &b);
}

[code]....

View 4 Replies View Related

C :: Scanning Equations / Functions Into Program

Nov 15, 2014

I have to make a numerical integration program, how I can write my code so that the user is able to write their own function that they want to integrate?

E.g. they would see the message: 'please enter your function' and would be able to write whatever they wanted e.g. 'x +5' then this would then be integrated by the program.

I have already written a program that can integrate a known function but would prefer that the user could choose their own.

View 2 Replies View Related

C++ :: Determine Roots Of Quadratic Equations?

May 23, 2013

I have given following exercise in my cpp book: Determine the roots of quadratic equations

ax^2 + bx + c = 0

using formula

x = -b +(plus-minus) (root)b^2 - 4ac/2a

i don't now how to write such code...

View 6 Replies View Related

C++ :: Solving Linear System Of Equations Using Threads

Dec 14, 2014

I am trying to write a code that solves a system of linear equations such as A*B=C. My system has a dimension equal to 1600. The matrix A cab be separated into 4 sub matrices and each can be handled by a different thread. I tried to solve this using the following code:

int main() {
int count = 0;
//Inputing matrix A
ifstream matrix;
matrix.open("example.txt");

[Code] ....

Although the above code gives the correct answer, the time needs to find the solution is bigger than that needed without using threads.

View 1 Replies View Related

C++ :: Finite Difference Method For Partial Differential Equations?

Nov 10, 2013

Calculated by the explicit scheme. Produces some very large numbers.

task:

[math] U_t = 3 (1,1-0,5 x) U_ {xx} + e ^ t-1 [/ math]
[math] U (0, t) = 0 [/ math]
[math] U (1, t) = 0 [/ math]
[math] U (x, 0) = 0.01 (1-x) x [/ math]

Need to find a solution with accuracy [math] 0.0001 [/ math] on the interval [math] T = 1 / a ^ *, where a ^ * = max a (x, t) [/ math] Plot graphs of functions [math] u (x ^ *, t), u (x, jt ^ *) [/ math] where [math] x ^ * = 0.6, t ^ * = T/10, j = 1,2,4 [/ math]

explicit difference scheme is as follows:

([math] $ u_t ^ {j +1}-u_i ^ j) / tau = 3 (1,1-0,5 x_i) (u_ {i +1} ^ {j}-2u_i ^ j + u_ {i -1} ^ j) / h ^ 2 + e ^ {t_j} +1 $ $ [/ math]

code of the program:

int main ( void ) {
setlocale(LC_ALL, "rus");
int I = 10, J = 30, i, j;
double T = 1.0/ pow(3.3, 0.5), h_x = 1.0/ I, h_t = T/ J, epsilon = h_t + pow(h_x, 2), c;
double **u = new double *[I + 1];
for (i = 0; i <= I; i++) u[i] = new double [J + 1];

[code]....

displays the following:

[URL]

View 2 Replies View Related

Visual C++ :: Pthreads - Solve System Of Equations By Gauss-Jordan Method

Dec 15, 2012

I have a problem: solve the system of equations by the Gauss-Jordan methods with pthreads. I have a big matrix A (for example 2000x2000), so i must solve Ax = b. Before I devide matrix to number of threads and each thread must work only with his peace of matrix.

Code:
#include <iostream>
#include "synchronize.h"
#include <pthread.h>
using namespace std;
typedef struct _ARGS {
int thread_count;
int thread_number;

[Code] .....

I write it on Ubuntu, and when I compile [g++ main.cpp -o main -lpthread -lm] the it works good(for example, if in 1 thread I get time_of_working = 10 sec, on 2 threads time_of_working = 5.4, i.e. about 2 times faster ), if I compile like this [g++ main.cpp -o main -lpthread -lm -O3] it is only 1.2-1.3 times faster.

View 1 Replies View Related

C++ :: G++ / Why Is -L Not Working

Mar 6, 2015

Whenever I put my dll files in the same directory as my main.cpp and use this code, Code: g++ main.cpp -L. -lMyDll it works.

but if my dll files are in the other directory, Code: g++ main.cpp -L/myDlls -lMyDll it won't work. Why is this not working?

View 6 Replies View Related

C :: Get SDL Working

Jul 5, 2014

i am currently trying to get SDL working with C language.I am using Cygwin and Sublime text 2.I know and understand general programming, however i am trying to understand how to get SDL working with a file i create i.e test.c. i know to include which i have downloaded

#include <SDL.h>

where do i add the libraries so that i can use them in my program?

View 9 Replies View Related

C++ :: Irc Bot Not Working?

Apr 16, 2014

I am writing an irc bot in c++ on linux mint, and its not connecting right for some reason. anyways, heres the link: [URL].... . it was connecting to quakenet before I added the functions, but now it just says connecting... and then quits.

View 12 Replies View Related

C++ :: Irc Bot Not Working

Apr 3, 2013

I'm learning network programming and I've decided to program a simple c++ irc bot. I'm able to connect to server and send commands. But when I try to receive and show message from server I first get a few lines, like "Please, wait, while we process your connection" or "Found your hostname". And then I start to get a ton of information about the server. Here is the whole class:

header file:

#pragma once
#include <WinSock2.h>
#include <WS2tcpip.h>
class bot {
public:
bot(char *_server, char *_port);
~bot(void);

[Code] .....

Link to whole visual studio project: [URL] .... Am I doing something wrong during the IRC connection? Or I didn't understand how networking work?

View 19 Replies View Related

C++ :: Set Insert Not Working?

Jul 25, 2014

When inserting elements in a set it should only insert unique elements but I get duplicates too.

Code: #include <iostream> // cout
#include <algorithm> // unique, distance
#include <string>
#include <iterator> // std::back_inserter

[Code].....

View 3 Replies View Related

C :: If Statement Not Working

Oct 21, 2013

Well for some reason this doesn't work.

Code:

#include <stdio.h>#include <ctype.h>
int main(void)
{
int lottoNums[150];
int num;

[Code]....

View 13 Replies View Related

C :: Mod Function Not Working

Nov 27, 2013

Code:
#include <stdio.h>
int main() {
int m,c;

for(c=0;c<100;c++) {
m = c % 10;
printf("%d ",m);
}
return(0);
}

When I run this code in my compiler, I get the first nine or ten numbers, and then after that it just spells out the letters in my name in different sequences over and over.

View 3 Replies View Related

C :: Fclose Seems To Be Not Working

Mar 6, 2015

I'm trying to write a code that will

1) Generate a series of numbers
2) Write those numbers onto a txt file and
3) Read only the odd numbers out of the txt file.

I have 3 functions besides main that do each of the objectives individually and when separate they work just fine. But when I put them together for some reason the third function is never started. Also when I rearrange the 3rd function infront of the 2nd (since i have the txt file already saved) it works but I get an error when trying to close the txt file. It is the same close function that I'm using when first creating the txt file as well.

Here is the code

Code:

#include <stdio.h>
#include <stdlib.h>
int main()
}

[code]....

View 3 Replies View Related

C++ :: Working On 2 Axis The Same Way

Aug 13, 2013

I have been coding this 2D physic engine for quite some time, I work on the many part of these 2 axis ( x and y ) in the same manner is just that one is an x and one is y

So there is a lot of duplicate code

If there is a bug in one part I have to fix the other axis too which becomes a hazzle because I have to fix the duplicates too. The sample code from my program

for( auto it =bodies.begin(); it != bodies.end(); ++ it ){
sf::Vector2f velocity = it->getVelocity();
if( velocity.x != 0 ){
// do some friction force calculation

[Code] ...

It is even more of a hazzle when I work with 4 quadrant, I have 4 duplicate code each ... How do I write a function for both axis ?

View 9 Replies View Related

C/C++ :: SDL App Not Working On Other Computers

Jun 2, 2013

My SDL app which i made in visual c++ works properly on my pc, but it does not even starts on other computers. I have pasted all the required .dll files in my debug folder along with the pictures and sounds.

View 4 Replies View Related

C++ :: Case Statement Not Working?

Mar 6, 2015

I have this case statement that is not performing as expected. For some reason ASE_OK and ASE_NotPresent both print out. Why is this? ASE_OK is a return value of 0 while ASE_NotPresent is -1.

Code: // Try to create the buffers and store it
switch (theAsioDriver->createBuffers(info, numChannels, bufferSize, callbacksInfo)) {
case ASE_OK:
std::cout << "ASE_OK";
input->bufferSize = output->bufferSize = bufferSize; // Buffer size is stored in both input and output
case ASE_NotPresent:
std::cout << "ASE_NotPresent";
errorMessage = "Could not find input or output devices.";
return NO_DEVICES_FOUND;

[code]....

View 3 Replies View Related

C++ :: Eight Queens Program Not Working?

Feb 3, 2015

I'm a bit stuck on a program that prints out a 8x8 chessboard and Q to represent queens where the user enters input. The intended output is: Code: Enter the columns containing queens, in order by row: 0 3 4 0 0 7 6 7

Q.......
...Q....
....Q...
Q.......
Q.......
.......Q
......Q.
.......Q

but instead I get Code: Enter the columns containing queens, in order by row: 0 3 4 0 0 7 6 7

.Q
.Q
.Q
.Q
.Q
.Q

[code].....

View 2 Replies View Related

C++ :: Switch Statement Is Not Working?

Aug 16, 2014

okay so like case 2 and 3 is not working, also the program is still not finish but why isn't case 2 and 3 not functioning well on the switch part? case 1 works just fine

Code:
#include<stdio.h>
main ()
{
//passcode part (passcode is 1234)

[Code].....

View 5 Replies View Related

C++ :: Negative Numbers Not Working?

Jan 22, 2015

I have a program where the user inputs a line of numbers, and the two highest ones are displayed. It works fine, until negative values are entered at which point it shows 0 as the result.

Code: #include <iostream>
using namespace std;
int main( ) {
int num = 0;
int highest = 0;

[Code].....

View 6 Replies View Related

C++ :: Working With Files In Netbeans

Jul 26, 2013

I have created a project in netbeans 7.2 and have not modified any setting. I have used all sorts of methods I could think/find but the code can not find the file.

I have placed my test.txt file in the folder of the project. Here is the location of the file:

C:UsersSAMARASDocumentsNetBeansProjects
eadFi le

However, I could not use it without modifying it as an absolute path.

For example, check the code from the FAQ. //well the return 0; is missing but this is not the problem now.

Or for example this code Code: bad code or with Code: myReadFile.open("C:/Users/SAMARAS/Documents/NetBeansProjects eadFile est.txt"); I have tried many things for placing the slashes, but could not find the file.

View 6 Replies View Related

C :: Copy Of Struct Not Working

May 14, 2013

Code:
#include <stdio.h>
#include <stdlib.h>
typedef struct BOOK
{
int* price;
} Book;

[Code] ....

View 1 Replies View Related







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