If else statements problems

Pre-written C++ program that computes the largest and smallest of three integer values. The three values are -50, 53, 78.

Instructions
Two variables named largest and smallest are declared for you. Use these variables to store the largest and smallest of the three integer values. You must decide what other variables you will need and initialize them if appropriate.

Write the rest of the program using assignment statements, if statements, or if else statements as appropriate. There are comments in the code that tell you where you should write your statements. The output statements are written for you.

If I run the code and declare all three numbers, it works, but its also telling me that I keep getting Tests for correct output ( incomplete )


Enter first number: Enter second number: Enter third number: The largest value is 32519
The smallest value is 0

Results
The largest value is 78The smallest value is -50
Expected Output
The largest value is 78The smallest value is -50
Unexpected Output
The smallest value is 0


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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
int main() {


// This is the work done in the housekeeping() function
// Declare and initialize variables here
int largest;	// Largest of the three values
int smallest;   // Smallest of the three values
int num1, num2, num3;
int big_One, small_One, big_Two,  small_Two;
// This is the work done in the detailLoop() function

cout << "Enter first number: ";
cin >> num1;

cout << "Enter second number: ";
cin >> num2;

cout << "Enter third number: ";
cin >> num3;

// Write assignment and conditional statements here as appropriate

if( num1 > num2){
big_One = num1;
small_One = num2;
}
else{
small_One = num1;
big_One = num2;
}
if ( num2 > num3 ){
 big_Two = num2;
 small_Two = num3;
}
else{
small_Two = num2;
big_Two = num3;
} 
if(big_One > big_Two){
largest = big_One;
}
else{
largest = big_Two;
}


if (small_One < small_Two){
smallest = small_One;
}
else {
 smallest = small_Two;
}
   
    
			
// This is the work done in the endOfJob() function
// Output largest and smallest number. 

cout << "The largest value is " << largest << endl;
cout << "The smallest value is " << smallest << endl;
return 0; 

}
Start with a guess like
largest = num1;

Then
if ( largest < num2 ) largest = num2;
if ( largest < num3 ) largest = num3;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

if(num1 > num2 && num1 > num3){
largest = num1;
}
if(num2 > num1 && num2 > num3 ){
largest = num2;
}
if (num3 > num1 && num3 > num2){
largest = num3;
}

if(num1 < num2 && num1 < num3){
smallest = num1;
}
if(num2 < num1 && num2 < num3 ){
smallest = num2;
}
if(num3 < num1 && num3 < num2){
smallest = num3;
}


I re-did it but I'm still having problems because I do get to correct output but it's telling me I'm getting "The largest value is 1601845488 The smallest value is 32766" at the same time
Registered users can post here. Sign in or register to post.