this program does not read display smallest and largest values in order

#include<iostream>

using namespace std;

int main()
{

	int sum; 
	int product;
	double average;
	int x,y,z;
	int largest;
	int smallest;
	
	cout<<" Enter Three Integers of your Choice "<<endl;
	cout<<" *********************************** "<<endl;
	cin>> x >> y >> z;

	cout<<endl;

    smallest = x,y,z;

	largest = x,y,z;

	sum = x + y + z;
	
	product = x * y * z;

	average = double(sum)/3;
	if( x > y )
		if(x > z)
		x=largest;
	if( x < y )
		if(x < z)
		x=smallest;
	if( y > x )
		if(y > z )
	   y =largest;
	if(y < x )
		if(y < z)
		y=smallest;
	if( z > y )
		if(z > x)
		z =largest;
	if(z < y )
		if(z < x)
		z = smallest;

	
	cout<<" Sum "<<" \t "<<" Product "<<" \t "<<" Average "<<"\t"<<"smallest"<<"\t"<<"largest"<<endl;
	cout<<" *** "<<" \t "<<" ******* "<<" \t "<<" ******* "<<endl;
	cout<< sum <<" \t\t "<< product <<" \t\t "<< average <<"\t\t"<<smallest<<"\t\t"<<largest<<endl;

	cout<<endl;

	return 0;

}

this program does no display smallest and largest in order

#include<iostream>

using namespace std;

int main()
{

	int sum; 
	int product;
	double average;
	int x,y,z;
	int largest;
	int smallest;
	
	cout<<" Enter Three Integers of your Choice "<<endl;
	cout<<" *********************************** "<<endl;
	cin>> x >> y >> z;

	cout<<endl;

    smallest = x,y,z;

	largest = x,y,z;

	sum = x + y + z;
	
	product = x * y * z;

	average = double(sum)/3;
	if( x > y )
		if(x > z)
		x=largest;
	if( x < y )
		if(x < z)
		x=smallest;
	if( y > x )
		if(y > z )
	   y =largest;
	if(y < x )
		if(y < z)
		y=smallest;
	if( z > y )
		if(z > x)
		z =largest;
	if(z < y )
		if(z < x)
		z = smallest;

	
	cout<<" Sum "<<" \t "<<" Product "<<" \t "<<" Average "<<"\t"<<"smallest"<<"\t"<<"largest"<<endl;
	cout<<" *** "<<" \t "<<" ******* "<<" \t "<<" ******* "<<endl;
	cout<< sum <<" \t\t "<< product <<" \t\t "<< average <<"\t\t"<<smallest<<"\t\t"<<largest<<endl;

	cout<<endl;

	return 0;

}

my program cannot differentiate between smallest and largest, as when i run it display values in a wrong way

All of your assignment statements are backward. You need to reverse them (i.e. x=largest; should be largest=x; ).

Also, this section of code, while syntactically valid, is completely worthless:

smallest = x,y,z;

  largest = x,y,z;

Because of how the comma operator works, and because a variable can only hold a single value, it accomplishes nothing more than this:

smallest = z;

  largest = z;

You'd be better off just initializing them to zero (0) when you declare them...

Edited 5 Years Ago by Fbody: n/a

i no expert but i noticed A LOT of errors.

the error discussed by guys above is a start to the many errors i saw.
i dont know how much this will help you as you seem, what looks like to me very confused, and struggling with ideas,

but this is how i would edit to fix. i left your parts that seemed incorrect or unnecessary but just commented them out

#include<iostream>

using namespace std;

int main()
{

	int sum; 
	int product;
	double average;
	int x,y,z;
	int largest;
	int smallest;
	
	cout<<" Enter Three Integers of your Choice "<<endl;
	cout<<" *********************************** "<<endl;
	
    cout << "enter 1st integer" << endl;
    cin>> x ;
     
    
    cout << "enter 2nd integer" << endl;
    cin >> y;
    
    cout << "enter 3rd integer" << endl;
	cin >> z;
    //cout<<endl;

    //smallest = x,y,z;

	//largest = x,y,z;

	sum = x + y + z;
	
	product = x * y * z;

	average = (sum)/3;
	
    if( x > y)
		{
         if(x > z)
		 {
         largest = x;
         }
        }
    if( y > x  )
		{
         if(y > z)
		 {
         largest = y;
         }
        }
	if( z > y )
		{
         if(z > x)
		 {
         largest = z;
         }
        }
	
    if( x < y)
		{
         if(x < z)
		 {
         smallest = x;
         }
        }
    if( y < x  )
		{
         if(y < z)
		 {
         smallest = y;
         }
        }
	if( z < y )
		{
         if(z < x)
		 {
         smallest = z;
         }
        }
    
    
    
    /*if(y < x )
		if(y < z)
		y=smallest;
	if( z > y )
		if(z > x)
		z =largest;
	if(z < y )
		if(z < x)
		z = smallest;
*/
	cin.get();
	cout<<" Sum   "<<sum<<" Product    "<<product<<" Average    "<<average<< endl;
    
    cout << "  smallest   "<<smallest<<"   largest   "<< largest <<endl;
	//cout<<" *** "<<" \t "<<" ******* "<<" \t "<<" ******* "<<endl;
	
    //cout<< sum <<" \t\t "<< product <<" \t\t "<< average <<"\t\t"<<smallest<<"\t\t"<<largest<<endl;

	//cout<<endl;
    cin.get();
	return 0;

}

im just learning c++ and know how confused i was towards beginning i hope this helps.
repost questions ill try to clear up what did

Comments
What use is it to help people if all you are going to do is correct their program for them? What has he learned?
This article has been dead for over six months. Start a new discussion instead.