View Single Post
  #1   Spotlight this post!  
Unread 30-12-2009, 23:48
Overyourhead's Avatar
Overyourhead Overyourhead is offline
Josh
AKA: Josh
FTC #0154 (Renegade)
Team Role: Mentor
 
Join Date: Apr 2007
Rookie Year: 2006
Location: Rhode Island
Posts: 46
Overyourhead is a jewel in the roughOveryourhead is a jewel in the roughOveryourhead is a jewel in the rough
Send a message via AIM to Overyourhead
Kind of off topic c programming question.

Sorry if this is off topic, as it is not directly related to FIRST. I've recently started my intro to C programming class.One of my assignments is to write a program that will take 3 number inputs from the user and find the highest and lowest number of the three. I'm only working on the highest number right now.

I've gotten stuck where I am, maybe you guys can help me. Heres what I have so far. Thanks

#include "stdafx.h"


int _tmain(int argc, _TCHAR* argv[])
{
int input_1, /*Input from integer 1*/
input_2, /*Input from integer 2*/
input_3, /*Input from integer 3*/
high_value; /* Highest Value */


/* Collect integers from the user. */

printf("Please enter your first number:");
scanf("%d", &input_1);
printf("Please enter your second number:");
scanf("%d", &input_2);
printf("Please enter your third number:");
scanf("%d", &input_3);

/* Find the largest number *'


if (input_1 >= input_2 && input_1 >= input_3) {
high_value = input_2;

}
else if (input_2 >= input_2 && input_2 >= input_3) {
high_value = input_2;
}

else if (input_3 >= input_1 && input_3 >= input_2) {
high_value = input_3;
}



/*Display the highest and lowest numbers*/
printf("\n\nThe Largest number is %d. \n",&high_value);




return 0;
}
__________________
"Like the WWF, but for smart people." -George HW Bush
2008-2009 Team 154 FTC
RI Regional-Winning Alliance/PTC Design Award
18th Place in Atlanta (Franklin Division)
2007-2008 Team 154 FTC
Winning Alliance/Inspire Award -RI Regional
Semi-Finals MA Regional
Atlanta Quarter Finials 12th in division(Franklin Division)
2006-2007 FVC 3707
Winning Alliance/Connect Award-RI Regional
26th Place in Atlanta