How do you make an insertion sorting algoritm using a liked list, first of all, i really dont have the slightest idea about link list, can anyone pleeeeeeeeeaaaaaaase help me.... :?: :?: :?: :?: :?: :cry: :cry:

#include <iostream>
using namespace std;


void instruction ();
float do_next_op ( float, float , char );


int main()
{
instruction();                      // displays instruction


float total;
float newentry;
char op;


total = 0;                           // initialisation


cin >> op;
while  (op != 'Q' && op != 'q' && op != '=')
{
cin >> newentry;
do_next_op (total, newentry, op);
cin >> op;
}
cout << "the final result is " << total << endl;


system ("pause");
return 0;
}



void instruction()
{
cout << endl;
cout << "*******************************************************" << endl;
cout << "                    CALCULATOR                    " << endl;
cout << "        the initial value is set to 0             " << endl;
cout << "   please enter an operator and a number to begin " << endl;
cout << "    the accepted operators are : + - * / ^ only   " << endl;
cout << "       enter a q, Q or = to exit the program      " << endl;
cout << "*******************************************************" << endl;
cout << endl;
}


float do_next_op ( float total, float newentry, char op)
{
switch (op)
{
case '+': total = total + newentry;
break;
case '-': total = total - newentry;
break;
case '*': total = total * newentry;
break;
case '/': total = total / newentry;
if (newentry == 0)
{
cout << "divide by zero is unexecutable" << endl;
}
break;
case '^': total =  pow (total,newentry);
break;
default : cout << "  Unacceptable Operator(" << op << ")" << endl;
}
cout << "result so far is " << total << endl;
cout << endl;


return (total);
}

Edited 3 Years Ago by happygeek: fixed formatting

help me to answer the product of first 10 even numbers in c++ program

Two posters posting the same code :eek: . now what is happening.

This article has been dead for over six months. Start a new discussion instead.