This is so great! This is a great board, a lot of helpful people here and I look forward to learning a lot here. I just finished "Teach Yourself C++ in 21 Days", so I'm not a complete newb, but I definately need to learn a lot more. So everyone prepare for my MANY MANY questions!
Heres a question to get things rolling
The only thing I couldn't get to work is for this program to use integers it receives from the command line. How can I get this to work? Thanks.Code:// Triangle computation program
#include <iostream>
using namespace std;
int main(int argc, int *argv[])
{
int a, b, c;
//cout << argch[0];
cout << "\n";
cout << argv[1];
cout << argv[2];
cout << argv[3];
if (argc > 4 || (argc < 4 && argc > 1))
{
cout << "Invalid number of sides.\n";
cout << "Implementation: <filename> sideA sideB sideC\n";
}
if (argc == 4)
{
a = argv[1];
b = argv[2];
c = argv[3];
cout << "Calculating based on given arguments.\n";
}
if(argc == 1)
{
cout << "Enter side 1: ";
cin >> a;
cout << "Enter side 2: ";
cin >> b;
cout << "Enter side 3: ";
cin >> c;
cout << "Calculating...\n";
}
if ( a == b && a == c && b == c )
cout << "This is an equilateral Triangle.\n\b";
if ( (a == b && a !=c) ||
(a == c && a !=b) ||
(b == c && b !=a) )
cout << "This is an isocles Triangle.\n\b";
if ( ((a*a)+(b*b)== (c*c)) ||
((b*b)+(c*c)== (a*a)) ||
((c*c)+(a*a)== (b*b)) )
cout << "This is a right triangle.\n\b";
else
cout << "Please check the numbers and try again!\n";
return 0;
}
-Peace