| My first if statement program. can't figure out problem. 
 
	 
	
		| Author | Message |   
		| Freakish 
 
 
 
 
 | 
			
				|  Posted: Wed Nov 02, 2005 7:49 pm    Post subject: My first if statement program. can't figure out problem. |  |   
				| 
 |  
				| I made this program after reading a tutorial on if statments. I keep getting an error when I run it but I can figure out how to fix it. 
 
 	  | code: |  	  | var num1 : int
var num2 : int
 var num3 : int
 var set1 : int
 var set2 : int
 var set3 : int
 var restart : string
 loop
 put "Enter your first number: " ..
 get num1
 put "Enter your second number: " ..
 get num2
 put "Enter your third number: " ..
 get num3
 %Number 1
 if num1 > num2 and num1 > num3 then
 set1 := num1
 elsif num1 < num2 and num1 > num3 then
 set2 := num1
 elsif num1 < num2 and num1 < num3 then
 set3 := num1
 %Number 2
 elsif num2 > num1 and num2 > num3 then
 set1 := num2
 elsif num2 < num1 and num2 > num3 then
 set2 := num2
 elsif num2 < num1 and num2 < num3 then
 set3 := num2
 %Number 3
 elsif num3 > num1 and num3 > num2 then
 set1 := num3
 elsif num3 < num1 and num3 > num2 then
 set2 := num3
 elsif num3 < num1 and num3 < num2 then
 set3 := num3
 end if
 if set1 = set2 or set1 = set3 or set2 = set3 then
 put "Two of your numbers are the same."
 elsif set1 not= set2 and set1 not= set3 and set2 not= set3 then
 put set1, set2, set3
 end if
 put "Restart y/n: " ..
 get restart
 exit when restart = "n"
 end loop
 
 | 
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| Sponsor Sponsor
 
  
   |  |   
		|  |   
		| Cervantes 
 
  
 
 
 | 
			
				|  Posted: Wed Nov 02, 2005 8:56 pm    Post subject: (No subject) |  |   
				| 
 |  
				| In that if-[elsif ... elsif]-endif structure, only one if statement can be entered.  In each one you give a value to one of set1, set2, or set3.  The other two are never given a value.  You then try to compare them, but you can't, since two of them never got a value. 
 Fixing it would be to ensure that set1, set2, and set3 all have values.  Alternatively, you could do away with set1, set2, and set3 (whatever they are).
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| xXInsanityXx 
 
  
 
 
 | 
			
				|  Posted: Wed Nov 02, 2005 9:25 pm    Post subject: (No subject) |  |   
				| 
 |  
				| Cervantes has already answered your question, but out of curiosity i have a couple of questions
 
 1. What is the purpose of this program?
 2. Is it trying to compare the numbers or trying to check if they are the same?
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		|  |  
 |