Hello guys, i am trying to write an insertion sort program with any values entered by any users but im getting some weird numbers. could someone help me see what s wrong with my code. this is my code:

#include <iostream>
using namespace std;
int main()
{

int a,b,c,d,e,f;
int array[6]= {a,b,c,d,e,f};
int i,j,key;
cout <<"enter a value: ";
cin >> a;

cout <<"enter a value: ";
cin >> b;

cout <<"enter a value: ";
cin >> c;

cout <<"enter a value: ";
cin >> d;

cout <<"enter a value: ";
cin >> e;

cout <<"enter a value: ";
cin >> f;

for (j=1; j < 6; j++){

key = array[j];


for (i=j-1; (i>=0) && (array[i]>key); i--)

array[i+1]= array[i];

array[i+1]=key;}
for( i= 0; i< 6; i++)

cout<< array[i]<<" ";
return 0;
}

Didn't get an answer instantly and decided to just post your question again, did you?

That's not going to make you friends, you know. Now noone will bother to look at your question and try to help.

i won t do it again. i didn t know it was like that.

Closing down this double post, if you wish to reply to above question please post here

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.