Assign input values to certain variables

Hello everyone.

I am new to this website but I've seen nothing but wonderful people helping each other learn computer code and it's amazing to see the talent here. I wanted to formally introduce. I'm beginning my computer science major with the fundamentals of programming class in my college. So I am noob, I apologize in advanced for any stupid questions. Hope to be at everyone's level one day. :)

Now to the actual question.

I'm making a program where the user is allowed to enter any three numbers with the exception of negative numbers and 0.
It's supposed to form a triangle. So the least two sides have to sum more than the biggest side.

I got the algorithm to determine what type of triangle is but I revised my prompt and the user is allowed to enter any 3 numbers in any order. So I want to figure out how to get the 3 inputs and enter them into new variables ordered from least to greatest.

Here's what I have in my program.
If you want me to show more in my program I can, so please let me know what else to put. Thank you everyone! :)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 //variables
	char initial1;
	char initial2;
	char initial3;

	int n1;
	int n2;
	int n3;

	int tside1;
	int tside2;
	int tside3;

	//input data
	cout << "Enter your initials with a space between each letter: " << endl;
	cin >> initial1 >> initial2 >> initial3;

	cout << "Choose any three numbers, except 0 and negative numbers. " << endl;
	cout << "Enter the first number: " << endl; 
	cin >> n1;
	
	cout << "Enter the second number: " << endl;
	cin >> n2;

	cout << "Enter the last number: " << endl;
	cin >> n3;

	//Triangle forming

//where I plan to assign the "nX" variables into the "tsideX" variables
Haven't you been introduced to if() statements yet? You can do the following
(this is pseudocode btw)


declare side1, side2, side3
read side1, side2, side3
if any of the variables is smaller than 1
output not valid
end if
declare sum1, sum2, sum3
sum1 = side1+side2, sum2=side2+side3, sum3=side3+side1
if any of the sums is smaller than any of the sides
output not valid
end if

this is for testing if input is valid.
Topic archived. No new replies allowed.