Welcome to Dream.In.Code
Getting Help is Easy!

Join 86,254 Programmers. There are 2,121 online right now! Ask your question and get quick answers from Dream.In.Code experts. Join the #1 programming help community on the internet! Registration is fast and FREE... Join Now!

Chat LIVE With a Expert
Powered by LivePerson.com

Register to Make This Box Go Away!

Aligning If, Then, Else Statements

 
Reply to this topicStart new topic

Aligning If, Then, Else Statements

Boot_Up
post 4 Apr, 2008 - 12:23 PM
Post #1


New D.I.C Head

*
Joined: 4 Apr, 2008
Posts: 3



I am supposed to design a program with a loop that lets the user enter a series of numbers and enter -99 to signal the end. And it also has to display the largest and smallest numbers entered. I chose to say only 3 numbers because I thought it would help with the length of the program. I am getting confused on the If, Then, Else statement alignment and also where to put the -99 to end the program. Everything is starting to run together. I just need some clarification on what I'm doing. I'm doing the very basic, there isn't a specific programming code that's used. By the way, I am Very new at programming but here's what I have so far.

CODE


Display "Enter a series of 3 numbers (or -99 to end)”

Display "Enter first number.”
Input num1
Display "Enter second number.”
Input num2
Display "Enter third number.”
Input num3

If num1>=num2 Then
    If num1>=num3 Then
      Display "Largest Number is , "num1”
    Else
        If num2<=num3 Then
                 Display "Smallest Number is , "num2”
        Else
                      Display "Smallest Number is , "num3”
      Else
             Display "Largest Number is , "num3”
                     Display "Smallest Number is , "num2”
      Else
                     If num2>=num3 Then
                            Display "Largest Number is , "num2”
                     If num1<=num3 Then
                            Display "Smallest Number is , "num1”
                Else
                     Display "Smallest Number is , "num3”
                Else
                     Display "Largest Number is , "num3”
                     Display "Smallest Number is , "num1”
                End If  
End If

User is offlineProfile CardPM
Go to the top of the page
+Quote Post


MRJ
post 4 Apr, 2008 - 01:03 PM
Post #2


D.I.C Head

Group Icon
Joined: 13 Oct, 2007
Posts: 53

What you have in your code isn't a loop.

What you want to do is store the High and Low:

CODE

int LowNum
int HighNum
int CurNum

loop whileCurNum <>-99
Display "Enter first number"
input CurNum

if CurNum <LowNum then LowNum=CurNum
if CurNum >HighNum then HighNum=CurNum

end loop
Display "Largest Number is , " HighNum
Display "Smallest Number is , " LowNum


User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 5/16/08 09:27AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month