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.

Code:#include <stdio.h> #include <stdlib.h> #include <limits.h> int main() { int a; /*user input 1*/ int b; /*user input 2*/ int c; /*user input 3*/ int d; /*user input 4*/ int sum; /*sum a, b, c, & d*/ int product; /*product a, b, c, & d*/ int average; /*average a, b, c, & d*/ int secsmall; /*second smallest among 4 integers*/ int small; /*second smallest among 4 integers*/ int ratio; /*ratio of second smallest to smallest*/ printf("\nPlease enter four different integers: "); scanf("%d", &a); scanf("%d", &b); scanf("%d", &c); scanf("%d", &d); sum=a+b+c+d; /*compute sum*/ printf("\nSum is: %d\n\n", sum); product=a*b*c*d; /*compute product*/ printf("Product is: %d\n\n", product); average=((a+b+c+d)/4); /*compute average*/ printf("Average is: %d\n\n", average); small=a; if(small>b) small=b; if(small>c) small=c; if(small>d) small=d; /*compute smallest*/ if(small<a) secsmall=a; if(secsmall>b) secsmall=b; if(secsmall>c) secsmall=c; if(secsmall>d) secsmall=d; /*compute second smallest*/ printf("Second Smallest is: %d\n\n", secsmall); printf("Smallest is: %d\n\n", small); ratio=secsmall/small; printf("Second Smallest / Smallest is: %d\n\n", ratio); printf("*****Program Terminated*****\n\n"); return (EXIT_SUCCESS); }