[QUOTE=Jookia;44458042]As far as I know in the industry, there's no standard for flowchart representations of code or desk checks. Which is good, because it means you can do it whichever way you want. As high level or low level as you wish. In whatever language you want. Personally I desk check in my head and write flowcharts on a notepad (I can't visualize these oddly) and finalize them on a computer.
Your biggest obstacle right now would be your educators who choose what to accept, and unless they've provided any specifications on how to format things, I'd say it's fair game.[/QUOTE]
So based on these...
[IMG]http://i57.tinypic.com/2hn45xx.jpg[/IMG]
You'd say my flowchart would be okay?
Yes.
Awesome, I'll go and find more questions to practice on.
Thanks heaps.
[QUOTE=trashmaster;44452211]How can I make a shader an effect similar to this?(GLSL)
[IMG]http://www.klopfenstein.net/public/Uploads/lorenz/xna_contest/xna_08_final.jpg[/IMG]
I've already modified a shader I got by googling, this is what it looks like now:[IMG]http://i.imgur.com/LIJxzwr.png[/IMG]
[/QUOTE]
Create a quad, in the vertex shader of the argument, check the range of the current UV coordinate to the center of the screen, and use that to only draw fragments inside of a circle.
Now using the range and an exponental increase of brightness, over a certain area of the edge you can create a nice glow.
you can add some randomness using noise or just a few sin waves, but the cloud in that example is probably a particle system, or at least a multitude of quads.
I'm not sure if this is the thread to ask, but I'm going to anyway (there don't seem to be any rules about not posting it here and I don't want to post a question thread.)
I am planning on [I]attempting[/I] to make a game. Yes, I know what this sounds like, but I'm not going to pull an 'ideas guy' thing.
Essentially, I want to make a 6DOF Stealth FPS. 6DOF meaning 6 degrees of freedom, and stealth FPS meaning in the shadows of a planet's orbit/shut-down space stations. It would be completely multiplayer.
It's an overly-ambitious goal, I know, but I can probably work on it on-and-off forever as there won't be any other games like it coming soon.
The gameplay would be more [URL="http://www.youtube.com/watch?v=Z_d24xkVRIk"]Shattered Horizon[/URL] Style than Descent Style, as it's supposed to take a while to play through a match, you would be able to shut down your suit computer, there would be bullet recoil and sound simulation etc.
To make it even more ambitious, I would have it so that the matches can be set up in a way that the orbit information, what place you start in the orbit, and what celestial body you start over can be decided beforehand. Orbits would be on-rails only, so that part's not complicated.
Here's the thing: if I wanted to do all that, what engine would be the best to use? I would pretty much need an engine that can handle 6DOF/quaternions, can fake orbits well, and do UI match setup stuff like stated above.
It doesn't have to be necessarily easy, because I have infinite time to work on it, but it would be appreciated all the same.
[QUOTE=FlandersNed;44459210][...]
Here's the thing: if I wanted to do all that, what engine would be the best to use? I would pretty much need an engine that can handle 6DOF/quaternions, can fake orbits well, and do UI match setup stuff like stated above.
It doesn't have to be necessarily easy, because I have infinite time to work on it, but it would be appreciated all the same.[/QUOTE]
Probably custom with just a framework for rendering. Existing ones mostly don't handle 6DOF too well, but if you can write a character controller you'd be able to use Unity for example.
I don't think any of them do orbits out of the box, but that's super easy compared to the other things you want to do.
[QUOTE=tui;44440680]Anyone familiar with the Mode7 effect of the Super Nintendo? I want to recreate that for a school project, so I already know I have to use a perspective transformation matrix to "ride" an image, but how can i achieve this in Java2D?[/QUOTE]
Aww yeah, I remember playing around with it, it was awesome.
I did it long long ago in LÖVE, so sorry I don't remember the algorithm, but you can see my and many others' sources in [url=https://love2d.org/forums/viewtopic.php?f=5&t=9984#p60977]LÖVE forum.[/url]
I believe it was very simple and easy effect that gave very beautiful results. I highly recommend anyone to play around with it.
Screenshot of mine:
[IMG]http://i.imgur.com/NFfh98A.png[/IMG]
[QUOTE=ks_uw-the_cat;44458035]Hello, members of community.
Can anyone tell me how disassemblers calculate absolute CALL/JMP address from an offset?
00000622 E8 89FA0000 CALL 000100B0h
For example, i have [B]CALL 000100B0h[/B] shown in debugger,
but real bytes are:
[B]00000622 E8 89FA0000[/B], where [B]00000622[/B] is address, where the instruction lies in, and
[B]E8 89FA0000[/B] is the instruction itself.
I'm just too confused :/[/QUOTE]
Well lets say for example you have this in the disassembler.
[code]006FEF80 - call 00701EA7 //E8 222F0000[/code]
What you want to do to find the offset is just
[code]
Function - (Location + 5) (Aka you want to subtract by the end of the code not the beginning)
00701EA7 - 006FEF85 = 00002F22
[/code]
Also remember to check the Endianness of your cpu. It's the difference between the offset being 12066 or 573505536.
The project I'm working on involves parsing XML and spitting it out in another syntax - currently, I'm using Python's standard etree library. I've hit a snag with how the library handles namespaces - specifically, I want it to leave namespace declarations and the like completely untouched.
Here is what I give it:
[code]<mdscript name="Smalltalk" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="md.xsd">[/code]
This is what I would want:
[code]mdscript(name=Smalltalk, xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance, xsi:noNamespaceSchemaLocation=md.xsd)[/code]
But this is what I get using the usual parse method:
[code]mdscript({http://www.w3.org/2001/XMLSchema-instance}noNamespaceSchemaLocation=md.xsd, name=Smalltalk)[/code]
As you can see, it's picked up on the namespace, prefixed the one attribute with its URI and completely omitted the other one. I've found a few resources online but all are about simply stripping the prefixes, not disabling the namespace handling entirely. Is there any way I can parse the XML 'verbatim' like this?
Is it a good idea to keep learning the same language if you are pretty new to programming instead of switching up in the beginning?
[QUOTE=JohanGS;44461728]Is it a good idea to keep learning the same language if you are pretty new to programming instead of switching up in the beginning?[/QUOTE]
Learn the same language, once you know every detail and if you want to switch another it will be just a matter of memorising syntax.
[img]http://i.imgur.com/SqJqgk0.png[/img]
No problem, I'll just switch the target!
[img]http://i.imgur.com/ManQ7Ot.png[/img]
Oh..
I am working on a game and was wondering how to handle collision detection and all that jazz. It's a 3d game where the player is mostly grounded on the 2d plane, being able to move up z-levels but for the most part I think I could make do with simple collision detection. However, one thing is worrying me and that is how to check for bullet collision. I don't want it to be a hitscan thing because I'd like to later implement things like lasers (which for some reason will shoot slowly) so I'm wondering how to do that sort of collision detection. How would I go about doing this? Would a raycast work? If so, how? I feel like it would be very computationally intensive though, especially if you have upwards of a hundred bullets flying.
Anyone knows how to get colors on PDCurses/Windows? My application displays O.K. on NCurses/Linux but the colors simply won't show up in windows.
[QUOTE=WTF Nuke;44463576]I am working on a game and was wondering how to handle collision detection and all that jazz. It's a 3d game where the player is mostly grounded on the 2d plane, being able to move up z-levels but for the most part I think I could make do with simple collision detection. However, one thing is worrying me and that is how to check for bullet collision. I don't want it to be a hitscan thing because I'd like to later implement things like lasers (which for some reason will shoot slowly) so I'm wondering how to do that sort of collision detection. How would I go about doing this? Would a raycast work? If so, how? I feel like it would be very computationally intensive though, especially if you have upwards of a hundred bullets flying.[/QUOTE]
Raycasts are [B]the[/B] most computationally inexpensive thing you can collide against arbitrary geometry (sphere-sphere and AABB-AABB is faster though).
If you only want a section, do the raycast and check how far it hits, you can use a (for example AABB-)broadphase though to speed things up by discarding far misses early on.
[QUOTE=Tamschi;44467935]Raycasts are [B]the[/B] most computationally inexpensive thing you can collide against arbitrary geometry (sphere-sphere and AABB-AABB is faster though).
If you only want a section, do the raycast and check how far it hits, you can use a (for example AABB-)broadphase though to speed things up by discarding far misses early on.[/QUOTE]
Alright so from the minor research I did I would basically have a ray-triangle check because all my models are made of triangles right? This would be done CPU side I assume, or GPU?
-snip-
Piece of advice, always read and then ask questions later or else you'll end up like me and figure out the problem after you post.
[QUOTE=WTF Nuke;44470054]Alright so from the minor research I did I would basically have a ray-triangle check because all my models are made of triangles right? This would be done CPU side I assume, or GPU?[/QUOTE]
Usually CPU, but you can make it work on the GPU somehow if you want.
I'm not sure at what point it becomes faster there.
[editline]6th April 2014[/editline]
Use bounding spheres to skip groups of triangles early!
Can somebody help me, I'm not sure if I got the process right, or what I'm doing wrong.
Basically I'm doing a 3D Software Renderer, I've got the translation, rotation, scaling and camera matrices all done.
The process as I think it should be is the mesh is defined in local coordinates, so like
[code]
Vertex[] vertices = new Vertex[]
{
new Vertex(-1, -1, -1),
new Vertex(0, 1, -1),
new Vertex(1, -1, -1),
new Vertex(0, -1, 1),
};
[/code]
Then some world transformation matrices are applied, like to position the mesh in the world, rotate etc, so this would be translating it to the mesh's world position(Model Matrix I think), then the camera matrix is applied to position it relative to the camera(View Matrix).
All this I have done, now the part I can't do is the projection matrix, this one should multiply with a vector, the final vertex position, it should divide each point's x and y by it's z and do some clipping with znear and zfar, plus stretch it with the FOV.
I've tried several projection matrices, what I can't do is get the final screen coordinates of each point.
The way I see it, the perspective projection matrix should not only do the perspective effect with the z divide, but transform the given point to screen coordinates, then afaik a viewport transformation matrix is applied to scale it to the screen size.
Here's how I think the transformation process should be:
[img]http://puu.sh/7YLCn.png[/img]
So again, my problem is I need a matrix that transforms my world coordinates to screen coordinates, afaik the perspective projection matrix should do this, but I can't get it to work.
Here's the projection matrix I'm using now:
[code]
public static Matrix4 CreateProjectionMatrix(double znear, double zfar, int width, int height, double fov)
{
double[,] ret = new double[4, 4];
double e = 1 / Math.Tan(MathUtil.GetRadian(fov) / 2.0);
double ar = width / height;
double zp = zfar + znear;
double zn = zfar - znear;
ret[0, 0] = e; ret[0, 1] = 0; ret[0, 2] = 0; ret[0, 3] = 0;
ret[1, 0] = 0; ret[1, 1] = e / ar; ret[1, 2] = 0; ret[1, 3] = 0;
ret[2, 0] = 0; ret[2, 1] = 0; ret[2, 2] = -(zp / zn); ret[2, 3] = -((2 * zfar * znear) / zn);
ret[3, 0] = 0; ret[3, 1] = 0; ret[3, 2] = -1; ret[3, 3] = 0;
return new Matrix4(ret);
}
[/code]
and the order I'm multiplying them:
[code]
public Matrix4 GetTransformationMatrixWithCamera()
{
Matrix4 translationm = Matrix4.CreateTranslationMatrix(Translation);
Matrix4 rotationm = Matrix4.CreateRotationMatrix(Rotation);
Matrix4 scalem = Matrix4.CreateScaleMatrix(Scale);
Matrix4 cameram = Camera.GetFullCameraMatrix();
//scale -> rotate -> translate -> camera
return cameram * (translationm * (rotationm * scalem));
}
public Matrix4 GetProjectedTransformationMatrixWithCamera()
{
Matrix4 projectionm = Projection.GetProjectionMatrix();
Matrix4 tranformationm = GetTransformationMatrixWithCamera();
Matrix4 ret = projectionm * tranformationm;
return ret;
}
[/code]
The other matrices work fine, like translation, rotation, camera, etc.
Would appreciate it if someone could explain to me what I should be doing, or what I'm doing wrong.
[highlight](User was banned for this post ("days of rating spam" - dai))[/highlight]
Quick question:
In the abstract, I got a bunch of randomly placed points on a giant flat surface (2D-Plane). I have a special point randomly placed on the plain. I want to test the points and see if they are within a certain distance of the special point, and return one of those points randomly. The problem is testing every point is time consuming and causing my program to lag. What is the fastest way of doing this?
pretty new to C++, and decided to try to make a basic calculator with my current knowledge. trying to use different functions, but not really working out like I want it to.
[code]#include "stdafx.h"
#include "iostream"
int firstNumber(int x);
int main()
{
using namespace std;
cout << "Enter first number: " << endl;
firstNumber;
cout << firstNumber << endl;
return 0;
}
int firstNumber(int x)
{
using namespace std;
cin >> x;
return x;
}[/code]
as far as I know, it should output "Enter first number", run the function firstNumber, get the input to x and return x to main. instead of doing that, it returns a random value from RAM without giving the user the ability to input anything before it ends. why is that?
[QUOTE=LurkerOfPeace;44472507]Can somebody help me, I'm not sure if I got the process right, or what I'm doing wrong.
Basically I'm doing a 3D Software Renderer, I've got the translation, rotation, scaling and camera matrices all done.
The process as I think it should be is the mesh is defined in local coordinates, so like
[code]
Vertex[] vertices = new Vertex[]
{
new Vertex(-1, -1, -1),
new Vertex(0, 1, -1),
new Vertex(1, -1, -1),
new Vertex(0, -1, 1),
};
[/code]
Then some world transformation matrices are applied, like to position the mesh in the world, rotate etc, so this would be translating it to the mesh's world position(Model Matrix I think), then the camera matrix is applied to position it relative to the camera(View Matrix).
All this I have done, now the part I can't do is the projection matrix, this one should multiply with a vector, the final vertex position, it should divide each point's x and y by it's z and do some clipping with znear and zfar, plus stretch it with the FOV.
I've tried several projection matrices, what I can't do is get the final screen coordinates of each point.
The way I see it, the perspective projection matrix should not only do the perspective effect with the z divide, but transform the given point to screen coordinates, then afaik a viewport transformation matrix is applied to scale it to the screen size.
Here's how I think the transformation process should be:
[img]http://puu.sh/7YLCn.png[/img]
So again, my problem is I need a matrix that transforms my world coordinates to screen coordinates, afaik the perspective projection matrix should do this, but I can't get it to work.
Here's the projection matrix I'm using now:
[code]
public static Matrix4 CreateProjectionMatrix(double znear, double zfar, int width, int height, double fov)
{
double[,] ret = new double[4, 4];
double e = 1 / Math.Tan(MathUtil.GetRadian(fov) / 2.0);
double ar = width / height;
double zp = zfar + znear;
double zn = zfar - znear;
ret[0, 0] = e; ret[0, 1] = 0; ret[0, 2] = 0; ret[0, 3] = 0;
ret[1, 0] = 0; ret[1, 1] = e / ar; ret[1, 2] = 0; ret[1, 3] = 0;
ret[2, 0] = 0; ret[2, 1] = 0; ret[2, 2] = -(zp / zn); ret[2, 3] = -((2 * zfar * znear) / zn);
ret[3, 0] = 0; ret[3, 1] = 0; ret[3, 2] = -1; ret[3, 3] = 0;
return new Matrix4(ret);
}
[/code]
and the order I'm multiplying them:
[code]
public Matrix4 GetTransformationMatrixWithCamera()
{
Matrix4 translationm = Matrix4.CreateTranslationMatrix(Translation);
Matrix4 rotationm = Matrix4.CreateRotationMatrix(Rotation);
Matrix4 scalem = Matrix4.CreateScaleMatrix(Scale);
Matrix4 cameram = Camera.GetFullCameraMatrix();
//scale -> rotate -> translate -> camera
return cameram * (translationm * (rotationm * scalem));
}
public Matrix4 GetProjectedTransformationMatrixWithCamera()
{
Matrix4 projectionm = Projection.GetProjectionMatrix();
Matrix4 tranformationm = GetTransformationMatrixWithCamera();
Matrix4 ret = projectionm * tranformationm;
return ret;
}
[/code]
The other matrices work fine, like translation, rotation, camera, etc.
Would appreciate it if someone could explain to me what I should be doing, or what I'm doing wrong.[/QUOTE]
your model's vertices are in local space,
your model can have a model matrix with translation, rotation and scale (M matrix),
your camera can have camera matrix with translation, rotation (and scale) (V matrix),
then you also need a projection matrix if you aren't pleased with orthogonal views (P matrix) :)
and then you can do this:
PVM = P * V * M;
now you can multiply your vertices with PVM and you should get the correct coords for your screen.
(vertex is a 4 value array in this scenario, just add a 1.0 as 4th coord so you can multiply it with the matrix)
one more thing... the order of translation, rotation and scale is important...
[editline]6th April 2014[/editline]
[QUOTE=PredGD;44472879]pretty new to C++, and decided to try to make a basic calculator with my current knowledge. trying to use different functions, but not really working out like I want it to.
[code]#include "stdafx.h"
#include "iostream"
int firstNumber(int x);
int main()
{
using namespace std;
cout << "Enter first number: " << endl;
firstNumber;
cout << firstNumber << endl;
return 0;
}
int firstNumber(int x)
{
using namespace std;
cin >> x;
return x;
}[/code]
as far as I know, it should output "Enter first number", run the function firstNumber, get the input to x and return x to main. instead of doing that, it returns a random value from RAM without giving the user the ability to input anything before it ends. why is that?[/QUOTE]
you are not calling the function and you are returning the functions address i guess.
better change your function call line to this:
int return_value = firstNumber(xxx);
//while xxx should be a parameter
//now output the number
cout << return_value << endl;
//now your function can ignore the input parameter
int firstNumber(){
int x;
...
Edit:
forgot the parameter ...
[QUOTE=Xystus234;44472814]Quick question:
In the abstract, I got a bunch of randomly placed points on a giant flat surface (2D-Plane). I have a special point randomly placed on the plain. I want to test the points and see if they are within a certain distance of the special point, and return one of those points randomly. The problem is testing every point is time consuming and causing my program to lag. What is the fastest way of doing this?[/QUOTE]
A grid I think. If you place the points into cells you can quickly select the ones that are close enough (especially if the cells are ordered and you can jump directly into the array).
Just make sure you get all cells the hit circle touches, the ideal size will depend on the density you have.
[QUOTE=Pappschachtel;44473007]
you are not calling the function and you are returning the functions address i guess.
better change your function call line to this:
int return_value = firstNumber();
//while xxx should be a parameter
//now output the number
cout << return_value << endl;
//now your function can ignore the input parameter
int firstNumber(){
int x;
...[/QUOTE]
that made it work, thanks!
finished up the code, and now the compiler is saying that calculateNumber doesn't take 3 arguments. been pondering that for a while now, no clue what I could possibly do to fix that
[code]#include "stdafx.h"
#include "iostream"
double firstNumber();
double secondNumber();
char selectOperator();
double calculateNumber();
double printAnswer();
int main()
{
double nInput1 = firstNumber();
double nInput2 = secondNumber();
char op = selectOperator();
double solution = calculateNumber(nInput1, nInput2, op);
double printAnswer(solution);
}
double firstNumber(double x)
{
using namespace std;
cout << "Enter the first number: " << endl;
cin >> x;
return x;
}
double secondNumber(double z)
{
using namespace std;
cout << "Enter the second number: " << endl;
cin >> z;
return z;
}
char selectOperator(char op)
{
using namespace std;
cout << "Select operator to use: " << endl;
cin >> op;
return op;
}
double calculateNumber(double x, double z, char op)
{
using namespace std;
if (op == '+')
return x + z;
if (op == '-')
return x - z;
if (op == '/')
return x / z;
if (op == '*')
return x * z;
else
cout << "Unknown operator used." << endl;
}
double printAnswer(double solution)
{
using namespace std;
cout << "The answer is: " << solution << endl;
return 0;
}[/code]
[QUOTE=PredGD;44473660]that made it work, thanks!
finished up the code, and now the compiler is saying that calculateNumber doesn't take 3 arguments. been pondering that for a while now, no clue what I could possibly do to fix that
[code]#include "stdafx.h"
#include "iostream"
double firstNumber();
double secondNumber();
char selectOperator();
double calculateNumber();
double printAnswer();
int main()
{
double nInput1 = firstNumber();
double nInput2 = secondNumber();
char op = selectOperator();
double solution = calculateNumber(nInput1, nInput2, op);
double printAnswer(solution);
}
double firstNumber(double x)
{
using namespace std;
cout << "Enter the first number: " << endl;
cin >> x;
return x;
}
double secondNumber(double z)
{
using namespace std;
cout << "Enter the second number: " << endl;
cin >> z;
return z;
}
char selectOperator(char op)
{
using namespace std;
cout << "Select operator to use: " << endl;
cin >> op;
return op;
}
double calculateNumber(double x, double z, char op)
{
using namespace std;
if (op == '+')
return x + z;
if (op == '-')
return x - z;
if (op == '/')
return x / z;
if (op == '*')
return x * z;
else
cout << "Unknown operator used." << endl;
}
double printAnswer(double solution)
{
using namespace std;
cout << "The answer is: " << solution << endl;
return 0;
}[/code][/QUOTE]
first ... don't use the same namespace for every function. it's enough to do it once, like right under your includes or so.
second... your function declarations i guess it's called:
[CODE]double firstNumber();
double secondNumber();
char selectOperator();
double calculateNumber();
double printAnswer();[/CODE]
should have the same input parameters like your definitions...
so double calculateNumber(); should be double calculateNumber(double x, double z, char op);
and so on....
plus the function calculateNumber(double x, double z, char op); should always return a double, in every case!
and third:
[CODE]double firstNumber();
double secondNumber();
char selectOperator();[/CODE]
do not need any input parameters because you only output data... so you could just use a var inside the function.
example:
[CODE]double firstNumber(double x)
{
using namespace std;
cout << "Enter the first number: " << endl;
cin >> x;
return x;
}[/CODE]
should be
[CODE]double firstNumber()
{
double x;
cout << "Enter the first number: " << endl;
cin >> x;
return x;
}[/CODE]
[QUOTE=Pappschachtel;44474255]first ... don't use the same namespace for every function. it's enough to do it once, like right under your includes or so.
second... your function declarations i guess it's called:
should have the same input parameters like your definitions...
so double calculateNumber(); should be double calculateNumber(double x, double z, char op);
and so on....
plus the function calculateNumber(double x, double z, char op); should always return a double, in every case!
and third:
do not need any input parameters because you only output data... so you could just use a var inside the function.
example:
should be
[/QUOTE]
oops yeah, forgot to add my parameters in my forward declarations. works now! changed the code up with your advice, and the last issue I'm having is with my last function. I could use the calculateNumber function and have that output the answer, but I'd rather figure out why printAnswer isn't working like it should instead of working around it.
by the looks of it, the code completely ignores that function and ends itself after finishing up with calculateNumber.
[code]#include "stdafx.h"
#include "iostream"
using namespace std;
double firstNumber();
double secondNumber();
char selectOperator();
double calculateNumber(double x, double y, char op);
double printAnswer(double solution);
int main()
{
double nInput1 = firstNumber();
double nInput2 = secondNumber();
char op = selectOperator();
double solution = calculateNumber(nInput1, nInput2, op);
double printAnswer(solution);
}
double firstNumber()
{
double x;
cout << "Enter the first number: " << endl;
cin >> x;
return x;
}
double secondNumber()
{
double z;
cout << "Enter the second number: " << endl;
cin >> z;
return z;
}
char selectOperator()
{
char op;
cout << "Select operator to use: " << endl;
cin >> op;
return op;
}
double calculateNumber(double x, double z, char op)
{
if (op == '+')
return x + z;
if (op == '-')
return x - z;
if (op == '/')
return x / z;
if (op == '*')
cout << x * z << endl;
else
cout << "Unknown operator used." << endl;
}
double printAnswer(double solution)
{
cout << "The answer is: " << solution << endl;
return 0;
}[/code]
ignore the different code for the * operator, changed it to see if it would output that way
[QUOTE=JohnnyOnFlame;44465885]Anyone knows how to get colors on PDCurses/Windows? My application displays O.K. on NCurses/Linux but the colors simply won't show up in windows.[/QUOTE]
Turns out NCurses doesn't mind that you map the COLOR PAIR 0, but PDCurses will break colors completely.
Well, another one for the book of 'wat' that is undefined behaviour.
[code]
double calculateNumber(double x, double z, char op)
{
if (op == '+')
return x + z;
if (op == '-')
return x - z;
if (op == '/')
return x / z;
if (op == '*')
cout << x * z << endl;
else
cout << "Unknown operator used." << endl;
}
[/code]
little logic error there.
it checks all the ifs till the last one and if , and OLNLY if the last one is false you get into the else part,
what you maybe meant was if ALL the previous if operations were false then the else part ?
[QUOTE=Pappschachtel;44475035][code]
double calculateNumber(double x, double z, char op)
{
if (op == '+')
return x + z;
if (op == '-')
return x - z;
if (op == '/')
return x / z;
if (op == '*')
cout << x * z << endl;
else
cout << "Unknown operator used." << endl;
}
[/code]
little logic error there.
it checks all the ifs till the last one and if , and OLNLY if the last one is false you get into the else part,
what you maybe meant was if ALL the previous if operations were false then the else part ?[/QUOTE]
You need to use else if on every statement apart from first and last one
[QUOTE=djjkxbox360;44475852]You need to use else if on every statement apart from first and last one[/QUOTE]
I don't think that matters when they're all equality operators.
Sorry, you need to Log In to post a reply to this thread.