# Write a C++ program to sort 4 integers only using the if-else control structure no brute force tactic.

 Bob huginstien · March 8, 2015 Hello I can not seem to get a sequence of the same integer in the output, example if I typed in 1 1 1 1, it goes blank, or  1 2 2 1. But when I type in  2 4 5 3 its out put is  2 3 4 5.  Here is my code.  What am I doing wrong? #include #include using namespace std;int main (){    int a;    int b;    int c;    int d;    int smallest;     int biggest;    int middle1;    int middle2;    cout<<"Enter four integers here:\n"; // Enter  four numbers.    cin >> a;    cin >> b;    cin >> c:    cin >> d;    if ( a <= b)    smallest = a;    biggest = b;else ( b <= a)    {smallest = b;    biggest = a;}else if ( c <= smallest )  {       smallest = c;}  else if ( c >= biggest )   {biggest = c;}   else if (d < smallest)     {smallest = d;}   else if (d >= biggest)    {biggest = d;}else if ( a <= b )    {middle1 =a;    middle2 = b;}else if ( b <=a )    {middle1 = b;    middle2 = a;}else if ( c <= middle1)    {middle1=c ;} else if ( c >= middle2 )    middle2 =c ;  else if ( d <= middle1)    {middle1=d ;}else if ( d >= middle2 )    {middle2 =d ;}      return 0;}

## Replies

- page 2

 Bob huginstien · March 9, 2015 // Program to send four different permutations //// in integer form////***********************************************//#include #include using namespace std;int main(){ int a; int b; int c; int d; int smallestSofar; bool firstExcluded = false; bool secondExcluded = false; bool thirdExcluded = false; bool fourthExcluded = false; cout << "Enter four integers here:\n"; // Enter four numbers. cin >> a; cin >> b; cin >> c; cin >> d; smallestSofar = a; if (b#include #include #include #include using namespace std;int main(){ ifstream infile("input.txt"); //grabs file using filename if (!infile.is_open()) //checks if the file is open { cout << "unable to open file..so exiting from program " << endl; return 0; } int final_score, position, lineSize; //declares variables to be used double score, total, final_s; //declares doubles to be used string readLine, scoreAsString, totalAsString; //uses one string to read a line, one to get the score and one for the total char readCharacter; //declares a temporary character to check the next byte while (infile.peek() != EOF) //goes through all lines in the file { infile >> readLine; //puts a single line into readLine lineSize = readLine.size(); //calculates the linesize scoreAsString = ""; //resets the string to nothing totalAsString = ""; //resets the string to nothing for (position = 0; position (ceil(final_s)); cout << "Final Score is " << fixed << setprecision(5) << final_s << endl; if (final_score >= 90) cout << "Excellent" << endl; else if (final_score >= 80) cout << "Well Done" << endl; else if (final_score >= 70) cout << "Good" << endl; else if (final_score >= 60) cout << "Needs Improvement" << endl; else if (final_score <60) cout << "Fail" << endl; } infile.close(); return 0;}``
• 1
• 2

## C++

129,960 followers