sfuo 111 Practically a Master Poster

I was getting confused by the question and I think you were too.

I am pretty sure you are taking in an integer and passing that into a function that is going to return true or false.
If that returns false then ask for another input and repeat.
If it is true then take that number and pass it into a function that returns a double (number with a decimal) based on the range of values that falls between.

I do not think this program requires you to input a letter grade and instead it is just the numerical grade (which makes it simpler and cleaner).

This is what you should have and then you need to write out what the two functions do.

#include <iostream>
using namespace std;

bool validGrade( int ); //prototypes are always outside of main()
double convertGrade( int );

int main()
{
	int grade = 0;
	cout << "Input the students grade (0-100): ";
	cin >> grade;
	if( validGrade(grade) ) //check if the grade is valid
		cout << convertGrade(grade) << endl; //output the GPA
	return 0;
}


bool validGrade( int in )
{
	if( /* check the input against the range needed */ )
		return true; //if it meets the condition above
	return false;
}

double convertGrade( int in )
{
	if( /* */ ) //if it is greater than the highest mark
		return /* GPA value */; //return value of highest mark
	else if( /* */ ) //if it …
sfuo 111 Practically a Master Poster

I don't think that you can use switch statements with a range of values without typing in each value.

I would just stick with if/else statements for this assignment.

Start off by writing a validGrade() function have that take in an int and return true or false (a bool) then from there you would write a convertToLetterGrade() function and have that take in the grade (which is now valid) and have that function return a string based on the range of values grade falls in.

Edit: since some grades have a + or - by them you cannot just use a char you will need to use a string or char array. But this is C++ so I would use a string.

sfuo 111 Practically a Master Poster

That looks like you copy pasted it off someone elses post because of all the # sitting between the lines.

sfuo 111 Practically a Master Poster

Like 4olkata said use cin >> n1 >> n2 >> n3; because the comma does not work like that in C++.

Also abs(n1) does nothing because that will just return the absolute value of n1. You want n1 = abs(n1); because this will assign n1 to the absolute value of n1.

Then just to drop one check for the equilateral you only need if( n1 == n2 && n1 == n3 ) because that would mean that n2 and n3 are equal also.

sfuo 111 Practically a Master Poster

Since he wants it 1-99 you would divide by 99 not 100.

edit ** red goose is right this would give 1 for 99 and anything above. I don't know what I was thinking =)

sfuo 111 Practically a Master Poster

First of all you havent declared nSel any where but you are using it, so put int nSel = 0; before the cout lines or something (just before usage).

Then for your while loop you should make it so it loops while nSel is not 1 AND 2 not or. while((nSel != 1) && (nSel != 2))

ndowens commented: Helped me with my code issue +1
sfuo 111 Practically a Master Poster

From what you posted there are 2 problems.

Line 54 you need it to be else if not just else.
You cannot use else then a statement else acts as an "if the statement is not true do this instead" but else if checks the statement for another condition if the first one fails.

Then Line 56 you have mistyped first_digit.

sfuo 111 Practically a Master Poster

I switched made the function return a bool because you are returning false on a void function and ran it and it "broke" and made my motherboard speaker go off like a christmas song for like 3 min.

sfuo 111 Practically a Master Poster

You can make it as one process, just create a console application then put the window code into it and run it. You will see a the console window and a window pop up. All cin/cout usage will go to the console window and if you have your program/inputs set up properly you are going to be able to use that input to manipulate your window.

sfuo 111 Practically a Master Poster

Use a do{}while() to loop in main() I would not recommend calling main().

int main()
{
	char askLoop;
	do //do enters the loop weather or not the condition at the bottom is met on the first run
	{
		double tax, pay;
		termlength_determine();
		cout << "how much do you get paid per hour?: " << endl;
		cin >> pay;
		system("cls");
		cout << "How much tax do you get taken out of your check \n in percent form?:";
		cin >> tax;
		system("cls");
		gross_pay = hours_total * pay - (pay * (.01 * tax));
		cout << "your pay after taxes is: $" << gross_pay << endl;
		system("pause");
		askLoop_function();
	}while( askLoop == 1); //sets the condition for looping
	
	return 0;
}
sfuo 111 Practically a Master Poster

You can use the % (mod) operator to get the remainder of one number divided by another.

ie
72 % 10 = 2 <--- your first digit

sfuo 111 Practically a Master Poster

First off I would switch from Dev-C++ because it is a dead IDE. Use Code::Blocks or Visual C++ that is more current (I use Code::Blocks and had switched from Dev-C++ -- the transition wasn't that hard).

As for the whole having a window and cmd prompt up at the same time you just have to make a Console application type project and copy all the windowing code over (or just go Project >> options >> build targets and select Type: Console application for Code::Blocks).

If you do not know any WinAPI and would like to make windows I would recommend using Visual C++ (I think they have a GUI editor) or find an IDE that can make windows.

sfuo 111 Practically a Master Poster

I learned C++ from here and have found it to be a good reference website as well.

I would learn up to section Functions(I) then play around with input/output where you ask for name age and put it into a sentence or something basic like that. Get comfortable with the basics otherwise you will be lost later.

There are a few concepts that many new people find hard to grasp, such as pointers and memory references. When making small programs to learn these are not super important but later on these are huge and help with memory management among many other things. In other words look at them if you do not understand it the first time don't worry about it but do simple examples with them to understand how they work.

Good luck and remember to take it slow and right from the start I would recommend coding in a clean and easy to read format (don't be afraid to leave white space in code because no one wants to fight to read what you coded then try to find problems).

sfuo 111 Practically a Master Poster

If you are looking to make games I would go with C++/OpenGL or C++/DirectX or C#/XNA.

I have never used C# but since it is a newer language and since it was made by microsoft it would probably be very easy to make windows programs and games using their XNA framework.

From my experience C++ and OpenGL isnt that bad but you do need to play around with a whole bunch because the whole OpenGL library is written in C and sometimes it is a pain merging them together. Also just making a window in Windows with just C++/WINAPI takes many lines of code and is very specific to just making the window.

C++/DirectX is probably very similar to C++/OpenGL unless you use a good framework (personally I think GLUT for OpenGL is a total POS) but since I have never used it I can't really say.

If you have zero experience with programming let alone game making I think you should pick up C# and use the XNA framework to make the game. But first you will need to spend a good amount of time just learning the language and not even thinking about games as simple as tic tac toe. And if you plan on making a 3D game that requires a good grasp on Math and it is significantly harder than just a 2D game which can be difficult to make in the first place.


Just learn the basics very …

sfuo 111 Practically a Master Poster

Never even heard of decimal roman numerals but yeah if its like our number system you would think its the similar.

sfuo 111 Practically a Master Poster

Windows uses handles for letting the user/program control elements of the Windows environment (not 100% sure how to explain this).

So line 10 is getting the output handle and saving its memory address into the pointer hcon. This is then passed into SetConsoleTextAttribute() on line 11 and has its color attribute modified and since hcon is being modified and it is a pointer then the true console controller is then modified and the settings are changed.

Correct me if I'm wrong but I'm pretty sure this is generally how it works.

sfuo 111 Practically a Master Poster

It would take a while to write a program like this without flaws and you would have to think hard but if you look there is a pattern. There are never more than 3 of the same "digits" in a row and its always high digits to low digits, left to right, unless you are subtracting then you put a lower numeral before a higher one.

I would look at wikipedia they have a good part on roman numerals.

ie
So, for instance, 1234 may be thought of as "one thousand and two hundreds and three tens and four", obtaining M (one thousand) + CC (two hundreds) + XXX (thirty) + IV (four), for MCCXXXIV.

sfuo 111 Practically a Master Poster

Post exactly what you have in main.cpp because I can run it perfectly fine.

sfuo 111 Practically a Master Poster

Did you copy paste this and over write your whole main.cpp?

sfuo 111 Practically a Master Poster

After looking over your code the problem seems to be in main().

You have it so when you input your selection it sets the choice and the space THEN checks to see if the space is 0 or not. This will never be 0 because you are setting it before you check it. The easy fix to this is to set your choice check to see if that space is open with the while loop you have. Then set the space on the board.

Not sure if you are allowed to use arrays or anything but that since you are using a class I'll assume you can because it would condense your code by a ton.

This is a condenser/fix to your main() you can use it or you can just read the above and work it out yourself.

#include <iostream>
#include "tictactoe.h"

using namespace std;

int choice; //not gonna change this but I would either make myBoard global with choice or
			//put choice in with myBoard

int main()
{
	TicTacToe myBoard = TicTacToe();
	int playerTurn = 0; //keeps track of the players turn 0 = P1, 1 = P2

	cout<<"Enter the number of the space you wish to choose."<<endl;
	cout<<"The board spaces are as follows: "<<endl;
	cout<<"1|2|3" <<endl;
	cout<<"-|-|-" <<endl;
	cout<<"4|5|6"<<endl;
	cout<<"-|-|-"<<endl;
	cout<<"7|8|9\n"<<endl;
	
	while(!myBoard.getWin())
	{
		myBoard.setPlayerCode(playerTurn+1);
		cout<<"Player " << playerTurn+1 << ", enter the space you wish to choose: ";cin>>choice;
		myBoard.setPlayerChoice(choice);

		while(myBoard.getSpace()!=0)
		{
			cout<<"That space is not available, please choose another one: ";cin>>choice;
			myBoard.setPlayerChoice(choice);
		} …
sfuo 111 Practically a Master Poster
#include <iostream>

using namespace std;
int main()
{
	cout << "Hello world!" << endl;
	return 0;
}

This is the start of a program now go throw on some ints and add them together. Once that works figure out how to use a container ( list, vector, array... ) and put the numbers in there and then add them up.

sfuo 111 Practically a Master Poster

Took a while but I leveled up and it didn't crash. One big thing is that you have everything in one file which makes it really hard to find sections of the program.

So you could try dividing it up into headers and source files that organize the program into sections that make sense (ie spells, NPCs or other objects) and you could use classes to have monsters and the player as their own data type so it is easier to read.

I would recommend playing around with classes in a completely different program like having different shapes (rectangle and triangle) and having width height variables with an area function. And then try to implement it into a program like this. Other than that this program looks pretty good and it works.

sfuo 111 Practically a Master Poster

Your expe keeps building because you keep adding itself with the new random exp to itself. If you want to just add the amount of exp for killing that goblin then you need to just assign the random exp gained to expe (like you did for loot). In other words change expe = expe + rand() % 10 + 1; to expe = rand() % 10 + 1; As for the show exp until next level part it looks like you would need to take the next level exp required and subtract the texp you have from it. Or you can restructure the exp system and have variables called currentExp, expToLevel and currentLevel.

So random some exp after you kill the NPC and add that to currentExp and check if it becomes greater than ExpToLevel. If it is then go currentExp = currentExp % expToLevel (this will carry the extra exp from "over leveling" to the next level) and add 1 to level. Then just make expToLevel = currentLevel * 50 meaning that if you are level 1 then you need 50 exp, level 2 100 exp and so on.

sfuo 111 Practically a Master Poster

Personally I would start with just using a single variable instead of trying to make a list work because that just adds more complexity to something that you are trying to figure out. And if you are going to then just use the std namespace to shorten and clean the lines up until you learn it, then go back to adding the scope if you want to remove it.

Polymorphism is a special feature of inheritance, meaning you need to inherit class a into class b.

Also in order for this to work you need to make a list of pointers to an "a" class instead of having a list of instances of the "a" class otherwise it just outputs the character a because class "a" can be its own instance. You can change it so that class "a" is a pure virtual class by putting virtual void foo()=0; in class "a" but the usage is the same.

Here is the code using the virtual function foo() and not a pure-virtual function.

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

class a
{
	public:
	virtual void foo()
	{
		cout << "a";
	}
};

class b: public a //inherit class a
{
	public:
	void foo()
	{
		cout << "b";
	}
};

int main()
{
	list<a*> listOfA;
	b objectOfB;
	listOfA.push_front(&objectOfB);

	list<a*>::iterator it;
	for ( it = listOfA.begin(); it != listOfA.end(); it++)
		(*it)->foo();

	return 0;
}
sfuo 111 Practically a Master Poster

After testing out try and catch I couldn't get it to work and I cannot edit my last post to remove the end part where I tell you to go check that out to solve the problem. However I still recommend that website for reference/tutorials.

I looked around and found this which seems to work from what I have tested.

Just replace the line cin >> x; with the following:

if( !(cin >> x) )
{
	x = 0;
	cin.clear();
	cin.ignore();
}
sfuo 111 Practically a Master Poster

This example uses a do while loop to keep asking for the user input if it is not correct.

A do while loop will enter the loop no matter what the value of the variable that you are checking against is but will check at the end. In this case we do not care what the value of x is when we want the initial input but we want it to be between 1 and 3 in the end.

#include <iostream>
using namespace std;

int main()
{
	int x;
	do
	{
		cout << "Enter a number (1, 2 or 3): ";
		cin >> x;
	}while( x > 3 || x < 1 );
	cout << "You chose " << x << endl;

	return 0;
}

In order to get around the char input endless loop error you need to use try and catch which I would loop up here.

The website that I linked for reference is a very good tutorial/reference page and if you generally know what you are looking for it is easy to look up the usage.

sfuo 111 Practically a Master Poster

Way too much to see whats going on and the line numbers are off with your errors. Try to create a small program that uses your polygon class in a similar way to see whats going on with it.

Plus this is C++ why not use a vector (or another STL container) to hold your polygons in rather than a dynamic array.

sfuo 111 Practically a Master Poster

float rational would be of type float

rational myRationalNumber would be type rational

sfuo 111 Practically a Master Poster

This is an example using string stream and c++ strings using a similar format to what you posted above.

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

class DATE
{
	int day, month, year;

	public:

	DATE();
	DATE(string d);
	int GetDay();
	int GetMonth();
	int GetYear();

};

DATE::DATE( string d )
{
	stringstream s(stringstream::in | stringstream::out); //set up string stream for input/output
	s << d.substr(0,2) << " " << d.substr(2,2) << " " << d.substr(4,4) << " "; //divide the string up and put it into the stream
	s >> day; //pull out day
	s >> month; //pull out month
	s >> year; //pull out year
}

int DATE::GetDay()
{
	return day;
}

int DATE::GetMonth()
{
	return month;
}

int DATE::GetYear()
{
	return year;
}


int main()
{
	DATE myDate("11122010"); //input date as string
	cout << myDate.GetDay() << "/" << myDate.GetMonth() << "/" << myDate.GetYear() << endl;

	return 0;
}
sfuo 111 Practically a Master Poster

You can do 2 things for this.
#1 save all the points into a container and plot them each time
#2 make the board once outside of the infinite loop and plot the points on within the loop

The following code shows #2 because I think it is the best choice in this case

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

int main()
{
    int n, point;
    int position_x, position_y;

    do
    {
	cout << "Inpute Board size between 10 and 50" << endl;
	cin >> n;
    } while(n < 10 || n>50);

    int game_board[99][99];
    int value = 1;
    //create the board once
    for( int y = 0; y < n; y++ )
    {
        for( int x = 0; x < n; x++ )
        {
            game_board[x][y] = value++;
        }
    }

    do
    {
        cout << "Enter a point: ";
	cin >> point;
	position_y = point/n;
	position_x = (point%n)-1;

	game_board[position_x][position_y] = -1; //set the point on the board


	for( int y = 0; y < n; y++ )
	{
	    cout << endl;
	    for( int x = 0; x < n; x++ )
	    {
		if( game_board[x][y] <= 9 )
		{
	            cout << game_board[x][y] << " ";
		}
		else
		{
		    cout << game_board[x][y] << " ";
		}
	    }
	}
	cout << endl;
    } while(true);

    system("PAUSE");
    return 0;
}
sfuo 111 Practically a Master Poster

An easy way to think of a string is that its an array of characters in C and a vector of characters in C++.

Meaning it can hold any character. If you want something like " ' or \ in it you need to put an escape character before it like
mystring = "\\"
mystring = "\""

sfuo 111 Practically a Master Poster

I fixed it up so it actually runs but I removed the whole height_in_feet variable because it was not being used.

Since there are so many errors I would suggest you relearn the basics of functions.

Check this against yours and see where you went wrong.

#include <iostream>
using namespace std;

//prototypes
void Get_Data( int&, int& ); // reads the weight, height in feet, and height in inches
float Hat_Size( int ); // returns the hat size to the main
int Jacket_Size( int, int ); // returns the jacket size to the main
int Waist_Size( int ); // returns the waist size to the main
void Put_Data( float, int, int ); // writes the sizes

int main()
{
	int weight, height_in_inches;
	float Hat;
	int Jacket, Waist;

	//Read the Count for the Loop of
	int loop_target;

	cout << "Enter the Amount of Times You Would Like to Loop this Program : ";
	cin >> loop_target;

	for( int count = 0; count < loop_target; count++ )
	{
		Get_Data( weight, height_in_inches );
		Hat = Hat_Size( weight );
		Jacket = Jacket_Size( height_in_inches, weight );
		Waist = Waist_Size( weight );
		Put_Data( Hat, Jacket, Waist );
	}
	//system("PAUSE");

	return 0;
}


void Get_Data( int &weight, int &height_in_inches )
{
	cout << "Please Enter the Weight in Pounds:\n";
	cin >> weight;

	cout << "Please Enter the Height in Inches:\n";
	cin >> height_in_inches;
}

float Hat_Size( int weight )
{
	return (2.9)*(weight)/(4.9);
}

int Jacket_Size( int height_in_inches, int weight )
{
	return (height_in_inches)*(weight)/(288);
}

int …
sfuo 111 Practically a Master Poster

The problem that really stands out for me is your output area.

You are using cout << "text" << +a; and cout << "text" << +a+ "moretext" << +b << endl; When using cout only use + for adding numbers together.
For output you just need to go cout << "text" << a << "moretext" << b << endl;

sfuo 111 Practically a Master Poster

Try this

slong** newarray = 0;

for( int i = 0; i < limitsqr; i++ )
	newarray[i] = new slong[limit];
sfuo 111 Practically a Master Poster

Made a few changes to it and it works fine. Read the comments.

#include <iostream>
#include <string> //use string not cstring
using namespace std; //move using namespace std; up here

int main()
{
    string str2;
    cout<<"Enter a line of input for str2: ";
    getline (cin, str2);
    //remove cin >> str2;
    cout<<"Contents of str2: ";
    cout<<str2<<endl;

    return 0;
}
sfuo 111 Practically a Master Poster

The way you are doing it says int/int*(int*int)+int you want everything multiplied to be a float otherwise it converts it to an int.

1/2 gives the answer 0 because integers do not have decimals.
1.0/2.0 gives the answer 0.5 because doubles/floats do have decimals.

So the way to write what you want is 1.0/float(2*(iCount*2+1));

Since you know that iCount is always an integer you dont have to multiply by a float or add by a float but you have to convert all that into a float and put it under 1.0

sfuo 111 Practically a Master Poster

You need to add a break after case 1 because it just runs into case 2 which makes it output "twenty"

Here is another way to do this with strings and arrays.

using std::string;

int numToText(int num)                //function to return text version of number entered
{

    string ones[] = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten",
                    "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" };
    string tens[] = { "", "", "Twenty", "Thrity", "Fourty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety" };

    if( num < 20 )
        cout << ones[num] << endl;
    else
    {
        cout << tens[num/10];
        if( num % 10 != 0 )
            cout << "-" << ones[num%10];
        cout << endl;
    }
}
sfuo 111 Practically a Master Poster

A .dll file is a dynamic linker file which has to be included with the .exe if you do not use the static linker file. If you add the .a or .lib file (static linker) then you do not need the .dll file but the size of the .exe will be much larger.

Might be able to find the .lib/.a file on the mysql website

sfuo 111 Practically a Master Poster

Not sure why you are making it so complicated and you are using a int function when the way you have it you could use a void function.

int SumIt(int x, int y)
{
    if( x == y )
        return x;

    int high = x, low = x, sum = 0;

    if( y < x )
        low = y;
    else
        high = y;

    for( int i = low; i <= high; i++ ) //start from the low number and up until the highest number
        sum +=  i;

    return sum;
}
sfuo 111 Practically a Master Poster

I'm not sure what coefs is an array of (I'm guessing ints) but the pow() function returns a double so you would run into more casting problems there.

I would just use the c-style casting for this problem unless you need to use C++ style type-casting.

sum += coefs[i]*(int)pow((double)x, (double)degree);
sfuo 111 Practically a Master Poster

Yeah any translations/rotations done in projection modifies the camera and in modelview you are moving the objects.

sfuo 111 Practically a Master Poster

Move the camera back by translating (0,0,-10) units in matrix mode projection.

I know the basics of setting up OpenGL stuff but it looks like you are using java where I know it in C++.

sfuo 111 Practically a Master Poster

For that to work you would need to put individualBirth = Date(setDay, setMonth, setYear); Like Mike said just putting Date(setDay, setMonth, setYear); makes this class instance but it gets deleted after the semi-colon because it is not getting assigned/stored to anything.

If you make your class instance individualBirth equal to Date(setDay, setMonth, setYear) then the constructor that you just made will be copied to individualBirth because they are of the same data-type.

If you wrote 5 that does nothing but if you went int x = 5 that assigns 5 to the variable x. Writing Date(setDay, setMonth, setYear) is like the 5 in the example, on it's own it does nothing but it is able to be assigned to a variable and used later.

sfuo 111 Practically a Master Poster

I see other people have posted already but I am going to show what I did as well.

In the code I just put the Date class and anything to do with Date in because the Actor class was not fully shown in the code you posted.

I cleaned it up by throwing in do{}while() loops and took out variables that were being used but did not have to be there. Used 1 stringstream instead of 3 which I hope you can look at and understand how it works (it is like cin and cout).

Just read over the code and figure out what is going on then add in your Actor class either in a similar way or you can use your old code.

I see Mike posted his Foo Bar example I'm sure it teaches lots but I find examples that include what I am doing to be of more use.

#include <iostream>
#include <sstream>

using namespace std;

class Date
{
    int day, month, year;

    public:

    Date(){};
    
    bool validityDay(int);
    bool validityMonth(int);
    bool validityYear(int);

    string getCharacteristics();
};

bool Date::validityDay(int testDay)
{
    if(testDay >= 1 && testDay <= 31) //can be 31 days in a month
    {
        day = testDay; //set the day because it is valid
        return true;
    }
    else
        return false;
}

bool Date::validityMonth(int testMonth)
{
    if(testMonth >= 1 && testMonth <= 12)
    {
        month = testMonth; //set the month because it is valid
        return true;
    }
    else
        return false;
}

bool Date::validityYear(int …
sfuo 111 Practically a Master Poster

Could have something to do with depth.

Lets see some source code and then I'll be able to help you out more.

sfuo 111 Practically a Master Poster

Those are defined in the windows.h header and they are set that way for consistency since every data-type they have defined is in all capitals.

They have other ones like BYTE for char and a whole bunch more.

Just look up windows typedefs and you should find lots.

sfuo 111 Practically a Master Poster

I looked through your code and you should not use perspective when you are trying to render something that is 2D. So use glOrtho() this way everything is flat (no depth).

In your render() and initialize() functions remove gluLookAt();

And use this code for your SetupProject() function

void SetupProjection()
{
    glViewport(0, 0, windowWidth, windowHeight);        // reset the viewport to new dimensions
    glMatrixMode(GL_PROJECTION);            // set projection matrix current matrix
    glLoadIdentity();                       // reset projection matrix

    glOrtho(-windowWidth/2, windowWidth/2, -windowHeight/2, windowHeight/2, 1.0, 100.0); //sets ortho size to the window size (0,0 is the middle)
    glTranslatef(0, 0, -10); //moves the camera back 10 units so you can see what is being drawn in front of it
    glMatrixMode(GL_MODELVIEW);             // set modelview matrix
    glLoadIdentity();                       // reset modelview matrix
}

Also noticed that you do not have a on window resize function that will change your opengl drawing size. Ask if you need help not sure if this post is "dead" or not.

sfuo 111 Practically a Master Poster

OK if you went (2+2)%10 that would equal 4 because 4/10 has a remainder of 4
(7+7)%10 would give you 4 because it also has a remainder of 4

You do not know if you are going to have any numbers that are greater than 3 or any numbers below 3 and since it will not give you a wrong value by using %10 on all the digits it wouldn't hurt to just do it instead of making a big logic block trying to sort out if it is greater than or less than 3.

If you look back at the code I posted on line 22 that is where all the digits get split and have 7 added to them then they I used %10 on them to make them one digit. The code was posted so that you can look at it and see what is going on then if you want to put it back into your code you can see the logic in what had been done and understand how to implement it into your code.

sfuo 111 Practically a Master Poster

If you look at what I posted before I used %10.

for example

int x = 7+7;
x %= 10;
cout << x << endl; //this would output 4

% or mod or Modular is the remainder of the division.

for example 14/4 has a remainder of 2 but this will equal 3.
14%4 will equal 2 because that is the remainder.

edit: had wrong variable name so cout << num << endl; would not actually give you 4 (haha)

sfuo 111 Practically a Master Poster

This should do what you want need

int x = 6-7;
if( x < 0 )
    x += 10;