Download presentation
Presentation is loading. Please wait.
1
Decisions In today’s lesson we will look at:
what we mean by a decision the sorts of decisions a program might need to take programming a decision in BASIC
2
Decisions We need to make decisions all the time – what time to get up, what to eat, how to start your essay, etc. In programming, the word decision has the same sort of meaning. Can you think of a program that does exactly the same thing every time? Most programs make some sort of decision
3
Decisions What sort of things will your program make decisions based on? Your program might need to react to: what the user does what happens in the program the values of particular variables an external factor, such as date or time
4
Programming Decisions
Most programming languages – and even spreadsheets – use an if command to make a decision In BASIC, the format is: IF [test condition] THEN [command] For example... IF x > 10 THEN PRINT “X is bigger than 10”
5
Multiple Commands There is an expanded form of IF that allows you to do more than one thing: if a > b then a = a + b b = a – b a = a - b end if
6
Alternatives You can also use the ELSE command to give an alternative:
if a > 10 then print “a is bigger than 10” else print “a isn’t bigger than 10” end if
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.