Error(s) found: '1'

  • Unable to perform the query 'UPDATE cpp_code SET clickthru=clickthru+1 WHERE fid=4'. Table 'cpp_code' is read only.

  • C++ MADE EASY
    Code About Us Tutorial




       
     

    Home > myCode > Finding Highest Number

    November 30, 2009 1:47 am

       

    Finding Highest Number


    Posted on: 2001-09-09 01:44:25
    Number of times viewed: 275

     
     
    //This is a simple program that shows the user how to
    //sort and use for loops
    
    #include <iostream>
    using namespace std;
    
    
    void main()
    {
    	int Weight[5];
    	int SortedWeight[3];
    	int HWeight;
    	int HWeightIndex;
    	int i, j;
    
    	cout<<"Enter 5 Weights in Pounds: \n";
    	for(i = 0; i < 5; i ++)
    	{
    		cout <<"Weight#" << i+1 <<": ";
    		cin >> Weight[i];
    	}
    	for(i = 0; i < 3; i ++)
    	{
    		HWeight = 0;
    		for(j = 0; j < 5; j ++)
    		{
    			if(Weight[j] > HWeight)
    			{
    				HWeight = Weight[j];
    				HWeightIndex = j;
    			}
    		}
    			SortedWeight[i] = HWeight;
    			Weight[HWeightIndex] = 0;
    	}
    	cout <<"Highest Weight: " << SortedWeight[0] << " lbs" << "\n";
    	cout <<"2nd Highest Weight: " << SortedWeight[1] << " lbs" << "\n";
    	cout <<"3rd Highest Weight: " << SortedWeight[2] << " lbs" <<  endl;
    
    }

    Please Rate this Code:



     «12039» THINKQUEST TEAM C0111571 © 2001. All Rights Reserved.