i have to fix a program to make it enter integer numbers in any order. then i have to rearange the numbers from smallest to biggest using -IF ELSE- then i have to output the numbers. i have tried to figure it out but i cant make it work correctlly. any help would be appreciated. heres the code that i have
#include "stdafx.h"
using namespace System;
int main()
{int initial_input[3];
int order[3];
double average;
int count, total;
//initialize variables
count=0;
initial_input[0]=initial_input[1]=initia...
order[0]=order[1]=order[2]=0;
total=0;
average=0.0;
Console::Write("Enter three integer numbers :\n" );
while ( count %26lt; 3 ) {
initial_input[count]= Int32::Parse( Console::ReadLine() );
total=total+initial_input[count];
count = count+1;
}
if (initial_input[0]%26gt; initial_input[1]){
order[0]=initial_input[1];
order[1]=initial_input[0];}
else
{order[0]=initial_input[0];
order[1]=initial_input[1];
}
if (initial_input[0]%26gt; initial_input[2])
{order[2]=initial_input[0];
order[0]=initial_input[2];}
else
{order[2]=initial_input[2];
order[0]=initial_input[0];
}
if (initial_input[1]%26gt; initial_input[2]){
order[2]=initial_input[1];
order[1]=initial_input[2];}
else
{order[1]=initial_input[1];
order[2]=initial_input[2];
}
count=0;
Console::WriteLine("numbers in descending order \n");
while ( count %26lt; 3 ) {
Console::WriteLine(order[count].ToString... );
count = count+1; }
average = total / 3.0;
Console::WriteLine("\nAverage is {0}", average.ToString() );
return 0;
}
C++ programing help....if else?
for(int i=0;i%26lt;3;i++)
{
if (initial_input[i]%26gt; initial_input[i+1])
{
table[0]=initial_input[i];
initial_input[i]=initial_input[i+1];
initial_input[i+1]=table[0];
}
}
this is called buble sorting
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment