Possible Logic Error

This is a discussion on Possible Logic Error within the C Programming forums, part of the General Programming Boards category; Hi all,
I'm new to these boards, and programming in general. In fact, C is my first language. Earlier today, ...

Possible Logic Error

Hi all,

I'm new to these boards, and programming in general. In fact, C is my first language. Earlier today, my instructor gave an assignment that called for a program that, upon the input of 4 integers, outputs the sum, product, and average of those integers, along with displaying the lowest of the four, second lowest of the four, and the ratio of the second lowest to the lowest. I believe my issue resides in the logic for determining the second lowest of the four integers. I tried to use the same logic process as I did to compute the smallest integer (my instructor demonstrated this part in class). In addition, I think that I need to have the smallest integer defined before I compute the second lowest, but I'm not sure how to call down the smallest or what form of logic to use. My code is below. Any suggestions? Thanks for any help that can be given.

Sorry, I think I confused you. An array is not "separate, larger conditional statements". It's like a list or collection of things, say 100 numbers or 50 characters. Your program would be much easier if you were using arrays (read ahead in your book or take a quick glance here to see what arrays are). You do need to use more conditional statements to determine this, specifically you need to nest them (one inside another), like so:

Code:

if a is the smallest
secsmall = b
if c < secsmall
secsmall = c
if d < secsmal.
...
else if b is the smallest
secsmall = a
...

Thanks for the help! My roommate tried to explain nesting to me (he's far more versed in programming than I, but doesn't know C). We just couldn't figure out off the bat how to do that. I'll try that out and see what happens. Thanks again for the help and the quick response!

Here's the issue: after appending the program, it does not calculate the smallest integer correctly. This is probably an error in the way I set up the else...if statements, but I'm pretty sure I followed the format exactly out of the book.

Thanks again for all the help. I hate to continue to ask questions, but I really appreciate it.