I have a program in which tells me the highest number and the lowest number. ( i am using a loop for the highest and lowest)

I need to get the second highest and second lowest. without an array

i was wondering if i could find that within the same loop?

i already have the code for the largest and smallest
it just wont let me get the second largest and second smallest.

The user enters 30 numbers, find the second largest and second smallest

for(int i =0; i<30 ; i++)
if(input>maxi)
maxi=input;
if (input <mini)
mini=input;
//finds max and min

sure you can, as long as you keep an eye out for the biggest and smallest as well ..

(just piece of the logic, not actual code)

a = smallest, b = second smallest, c = input ...

if ( a > c )
b = a and a = c
else if ( b > c )
b = c

and about the same for biggest and second biggest

Then start a thread of your own with an actual question instead of hijacking someone else's old thread.

Closed.