Assistance with looping variances

Hello, I am trying to write a program that does sum, total & average, along with comparing numbers of being the highest and lowest. I've succeeded in do so, but am trying to write it different ways concerning the loops. The While loops and For loops have been completed, but I'm having problems doing the Do-While. Any help would be appreciated.
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
64
65
//while loop
#include<iostream>
using namespace std;

int main()
{
	float large, small, average, total, sum, a, b, c;
	int thirdnum, x = 1;	

	cout << "Please enter two numbers:";
	cin >> a >> b;	
	//comparing for high & low
	if( a > b)
	{
        large = a;
        small = b;
    }
    else
        {
        	large = b;
        	small = a;
		}
	//calculate sum
	sum = a + b;	
	//calculate total numbers entered
    total = 2;
	//calculate average
	average = sum / total;

	cout << "Do you wish to enter more numbers? Enter 1 for Yes or 2 for No:";
	cin >> 	thirdnum ;

	while (thirdnum == 1)
    {
		cout << "Please enter you number:";	
		cin >> c;
		sum = sum + c;
		total = total + 1;
		average = sum / total;
		if( c > large)
		{
        large = c;      
    	}
    	else
        {
        	if (c < small);
        	small = c;
		}		
		cout << "Do you wish to enter another numbers? Enter 1 for Y or 2 for N to continue:";
		cin >> x; 
		thirdnum = x;

		if (x == 2) 
		 {
			thirdnum = 2;
		 }	
	}        	
		cout << "The largest number is:" << large << "\n";
		cout << "The smallest number is: "  << small << "\n";
		cout << "The average is:" << average << "\n";
		cout << "The total number of numbers entered is:" << total << "\n";
		cout << "The sum of all numbers is:" << sum << "\n";
				
    return 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
//for loop
#include<iostream>
using namespace std;

int main()
{
	float large = 0, small = 0, sum = 0, average, total, x;
	int n;
	
	cout << "Please enter a number: ";
	
	for (int n=0; n < 6; n++) 
	{
		cin >> x;
		if( x > large)
		{
        	large = x;
    	}
    	else
        {
        	small = x;
		}
		sum = sum +x;
		//n is all the numbers
		//total = n;
		average = sum / n;
	}
  	
	cout << "The largest number is:" << large << "\n";
	cout << "The smallest number is: "  << small << "\n";
	cout << "The average is:" << average << "\n";
	cout << "The total number of numbers entered is:" << "6" << "\n";
	cout << "The sum of all numbers is:" << sum << "\n";
				
    return 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
//do-while loop
#include<iostream>
using namespace std;

int main()
{
	float large, small, average, total, sum, no, a, b, c;
	int thirdnum, x = 1;	

	cout << "Please enter two numbers:";
	cin >> a >> b;
	do {			
		//comparing for high & low
		if( a > b)
		{
        	large = a;
        	small = b;
    	}
    	else
        	{
        		large = b;
        		small = a;
			}
		//calculate sum
		sum = a + b;	
		//calculate total numbers entered
    	total = 2;
		//calculate average
		average = sum / total;
		
		cout << "Do you wish to enter more numbers? Enter 0 for No:";
		cin >> c;
			
	}
	while (c == 0);
    {        	
		cout << "The largest number is:" << large << "\n";
		cout << "The smallest number is: "  << small << "\n";
		cout << "The average is:" << average << "\n";
		cout << "The total number of numbers entered is:" << total << "\n";
		cout << "The sum of all numbers is:" << sum << "\n";
	}
    return 0;
}

indent your code

> but I'm having problems doing the Do-While.
¿what problems?
Topic archived. No new replies allowed.