Talk about absolutely anything here!
  • User avatar
  • User avatar
  • User avatar
  • User avatar
  • User avatar
  • User avatar
User avatar
By mtndewzane
#31122
fritterdonut wrote:Well I started working with C++ about an hour ago, and it doesn't seem too bad.

1. Grab a copy of Windows Visual C++ Express 2010

2. Go here : http://www.learncpp.com/

3. Learn.

An hour into doing the above steps and I already know how to make the program Bonejunky made... maybe I'll post mine as well :D

Ok easy things appeal to me not because I am lazy, but because I have school and possibly a job soon that will give me more things to do before I get to play Minerealm and learn to code.

and Thanks fritter. lol foreign as tex would say haha
User avatar
By fritterdonut
#31133
Well, I'm not going to bother posting the file itself, but heres the source for my Hypotenuse Calculator:
Code: Select all
// Project1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <cmath>
int main()
{
	std::cout << "Welcome to Fritter's Pythagorian Theorem Calculator" << std::endl;
	std::cout << "Please enter the length of the first side of a right triangle:";
	int x;
	// x is one side of the triangle
	std::cin >> x;
	std::cout << "Please enter the length of the second side of a right triangle:";
	int y;
	// y is the other side of the triangle
	std::cin >> y;
	int z;
	// z is the length of the last side
	z = ( ( x * x ) + ( y * y ) );
	z = sqrt(float(z));
	// above solves pythagorian theorem, a^2 + b^2 = c^2
	std::cout <<"The length of the hypotenuse is:" <<z<< std::endl;
	system("pause");
	return 0;
}
It ain't pretty, but it works.
User avatar
By Cheez99
#31134
system("pause");
I would avoid using system commands. You can do
cin.get();
cin.get();
instead.

also if do "using namespace std;" before main(), you don't need the scope operator (std::...).

My code:
Code: Select all
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    cout << "Enter the height of the triangle: ";
    float y = 0;
    cin >> y;

    cout << "\nEnter the length of the triangle: ";
    float x = 0;
    cin >> x;

    float z = sqrt((x * x) + (y * y));
    cout << "\nThe hypotenuse is " << z;
    cin.get();
    cin.get();

}
Tested and programmed in Code::Blocks, though I admit it's not really type-safe.
User avatar
By FaeynHeart
#31179
I usually use linux to do all my C++ programming. Just install gcc and build essentials = win. No IDE required, and debugging can all be done in the terminal. It is actually quite useful.
User avatar
By Sharingan616
#31183
mtndewzane wrote:I am not sure if I want to learn C, C++, or java.

I would love to learn all of them, but need to set my mind on one for now until I feel strong enough to learn another one.

Any suggestions. I know many code C and C++ , but Java would be nice to learn.
C++ is the most powerful of the three. It's better then C, and Java is weak. If you learn C++ very well Java shouldn't be too hard to learn afterwards.
User avatar
By FaeynHeart
#31184
I'm at work, so I can't do much but yeah :P
I like functions, I hate doing everything in main.
Let's keep building, someone add something :)
Code: Select all
#include <iostream>
#include <cmath>

using namespace std;

double hypotenuse(float a, float b)
{
 double c = sqrt((a*a) + (b*b));
    return (c);    
}

double angles(float& a, float& b)
{
  a = atan (a/b) * 180 / M_PI;
  b = 90 - a;       
}

int main(void)
{
    float y;
    float x;
    
    cout << "Height of the triangle: ";
    cin >> y;
    cout << "\nLength of the triangle: ";
    cin >> x;
    cout << "\nThe hypotenuse is: ";
    cout << hypotenuse(x,y) << "\n";
    
    cout << "The angles are: ";
    angles(x,y);
    cout << x << " and " << y;
    cin.get();
    cin.get();

}
EDIT: I was going to use inline asm just for fun but I don't know AT&T syntax, Intel is much easier.
By trollberry
#31211
Just for fun - the same thing in REBOL language :)
Code: Select all
rebol[]
hypotenuse: func [a b][return square-root((a * a) + (b * b))]
angles: func [a b][
	a: round/to arctangent (a / b) 0.01
	b: 90 - a
	return reduce [a "and" b]
]
prin "Height of the triangle: " y: to-decimal input
prin "Length of the triangle: " x: to-decimal input
print ["The hypotenuse is: " hypotenuse x y]
print ["The angles are: " angles x y]
input
quit
User avatar
By fritterdonut
#31413
Code: Select all
// Project1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <cmath>
int main()
{
   std::cout << "Welcome to Fritter's Pythagorian Theorem Calculator" << std::endl;
   std::cout << "Please enter the length of the first side of a right triangle:";
   float x;
   // x is one side of the triangle
   std::cin >> x;
   std::cout << "Please enter the length of the second side of a right triangle:";
   float y;
   // y is the other side of the triangle
   std::cin >> y;
   float z;
   // z is the length of the last side
   z = ( ( x * x ) + ( y * y ) );
   z = sqrt(float(z));
   // above solves pythagorian theorem, a^2 + b^2 = c^2
   std::cout <<"The length of the hypotenuse is:" <<z<< std::endl;
   system("pause");
   return 0;
}
Fixed my code :oops: because I was using int instead of float, I realized it rounded all answers to the nearest whole number, which didn't work very well at all!
User avatar
By Cheez99
#31417
Sharingan616 wrote:
mtndewzane wrote:I am not sure if I want to learn C, C++, or java.

I would love to learn all of them, but need to set my mind on one for now until I feel strong enough to learn another one.

Any suggestions. I know many code C and C++ , but Java would be nice to learn.
C++ is the most powerful of the three. It's better then C, and Java is weak. If you learn C++ very well Java shouldn't be too hard to learn afterwards.
While C++ is the most powerful, I would advise learning Java first. It's the easiest and has several features that make it harder for you to goof things up, like bounds checking. Java won't let you run out of the bounds of an array, but C++ will let you derp right off and never tell you. Java does garbage collection automatically too, so that's nice; however, I've never had to worry about it in C++.

Once you know Java, C++ is going to be easy to learn, and hopefully you'll have built up good habits and experience so that you won't make as many mistakes in C++.
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]