I know that im not supposed to write like this but i just want to know how to sort 4 random chosen numbers (chosen by pc) in ascending order. Just the basic insert. Imstill abeginnerand cant use arrays!

If you know not to, why are you?

You don't know how to use arrays, or you aren't allowed to use arrays? There is a big difference, and the answer drastically changes the required algorithm(s). Someone might help you if you answer that, and take some time to think about your algorithm.

Edited 6 Years Ago by Fbody: n/a

This is my algorithm and what ive got so far!!

#include <iostream>
#include <cstdlib>
#include <time.h>
using namespace std;
 int DICE_ROLL();
 int ARRANGE()
 int main(
  int argc, char* argv)
  {
     int numRolls;
     int arrRolls[6];
     int dieRoll;

     srand((unsigned)time(0));

     cout << "How many times would you like to roll the dice?" <<          endl;
     cin >> numRolls;

     for (int k = 0; k < 6; k++)
      {
         arrRolls[k] = 0;
       }

       for (int i = 1; i <= numRolls; i++)
      {
         dieRoll = DICE_ROLL();
         cout << "Die Roll " << i << ": " << dieRoll << endl;
         arrRolls[dieRoll - 1]++;
      }
      
      

     while (

                 for (int j = 0; j < 6; j++)
 {
           cout << "The number " << j + 1 << " was rolled " <<      arrRolls[j] << " times." << endl;
 }
 }

   int DICE_ROLL()
 {
       int result;

       result = (rand() % 6) + 1;

       return result;
   }

Edited 6 Years Ago by WaltP: Added CODE tags -- with all the help about them, how could you miss using them????

I assume your question is still sorting? I don't see any attempt so it's hard to know what you're having trouble with.

Start with a basic pencil & paper solution.
Write down these numbers.
5, 32, 12, 8
Step by step, how do you sort them if they were on a math assignment?

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