I just started C a few days ago in class and I've been working on a problem for well over 2 hours and still cannot figure it out. I am extremely noobish in this subject, so I was hoping someone can help me with this. I ran searches for about 30 minutes but I still did not understand the programs that some wrote because it is far more advance than I am right now.
The problem states:
Write a program that inputs three different integers from the keyboard, then prints the sum, the product, the average, the smallest and the largest of these numbers. Use only the single-selection form of the if statement.
I've gotten the sum, the product, and average to work but the smallest and the largest is making me go crazy. The teacher wants us to use the IF statements. something like this:
if ( num1 <= num2 ) {
printf( "%d is less than or equal to %d\n", num1, num2 );
This is what I got so far:
#include <stdio.h>
int main()
{
int x, y, z;
int sum;
int average;
int product;
printf( "Input 3 different integers: ");
scanf( "%d%d%d", &x, &y, &z );
sum = x + y + z;
average = (x + y + z)/3;
product = x * y * z;
printf( "Sum is %d\n", sum );
printf( "Average is %d\n", average);
printf( "Product is %d\n", product );
system ("pause");
return 0;
}
PLEASE HELP ME!!! This is one crazy labor day weekend.