Today I decided to solidify my familiarity of C++ by creating a couple rather useless, but working programs from scratch.

// Hypotenuse

#include

#include

#include

using namespace std;

int main()

{

int x; //position of x-axis

int y; //position of y-axis

int A; //square A + square B

float V; //resultant vector

cout << "Enter in both adjecants." << '\n';

cin >> x;

cin >> y;

A = (x * x) + (y * y);

V = sqrt ((double) A );

cout<< V << "\n"; //output of resultant vector

cin.get();

cin.get();

return 0;

}

#include

using namespace std;

/*The functions in this program are fired in the order of top to bottom for readability*/

void Readmatrix(int a, int b, int c, int d, int e, int f, intg, int h)

{

/*This function records the integers placed into each matrices’ variable*/

cout << "Enter in your first matrix (4 integers): ";

cin >> a;

cin >> b;

cin >> c;

cin >> d;

cout << "Enter in your second matrix (4 integers): ";

cin >> e;

cin >> f;

cin >> g;

cin >> h;

}

void multiply(int a, int b, int c, int d, int e, int f, intg, int h)

{

/*This is the algorithm for multiplying the matrices together. It is only compatible with 2×2 matrices*/

int a1, b1, c1, d1 = 0;

a1 = ((a * e) + (b * g));

b1 = ((a * f) + (b * h));

c1 = ((c * e) + (d * g));

d1 = ((c * f) + (d * h));

a = a1;

b = b1;

c = c1;

d = d1;

}

void Displaymatrix(int a, int b, int c, int d)

{

/*The functions simply displays the 2×2 matrix product*/

cout << a << " " << b << '\n' << c << " " << d;

}

int main()

{

/*The functions is my main loop, which calls all the above functions*/

char rawr;

do

{

int a, b, c, d, e, f, g, h = 0;

Readmatrix(a, b, c, d, e, f, g, h);

multiply(a, b, c, d, e, f, g, h);

Displaymatrix(a, b, c, d);

cout << endl;

cout <<"Would you like to do another matrix (y/n)? ";

cin >> rawr;

cout << endl;

} while ((rawr == ‘y’) || (rawr == ‘Y’));

return(0);

}

GreoHeh, pretty good. Course, programming a game will be more complex than this, but you’ll be there soon enough.

CecilSunkureHey thanks! Follow along with me if you want :D

Once I hit college, I’ll be posting what I learn here on this blog. Might be cool to follow along with me till then, so we can all start at the same level.

Patrick“This took me about 2 hours to complete, and about 25 minutes to write. Yep, that means I sat there and debugged the program for over an hour and a half. Sheesh, I hope this isn’t what programming is always like ;)”

If you think half an hour of debugging is a lot, you’re in for a nasy surprise. I’ve been known to a week working on a single bug, multiple hours a day. :P

CecilSunkureHour and a half, not half an hour. I didn’t actually think it was significant, it was just very annoying- hence my winking face ;)