Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS001 Introduction to Programming Day 2 Sujana Jyothi

Similar presentations


Presentation on theme: "CS001 Introduction to Programming Day 2 Sujana Jyothi"— Presentation transcript:

1 CS001 Introduction to Programming Day 2 Sujana Jyothi (sujana@cs.nuim.ie)sujana@cs.nuim.ie

2 2 What will you learn today? Useful Terms in Programming Sequence & Selection

3 3 Resources –Use the material from my website. http://www.cs.may.ie/~Sujana/CS001.html Save your work –on your flash drive –or email it to yourself

4 What is programming? Technical Common Sense Logical Thinking & execution simpler than logic puzzles Need not be a cryptic activity Concepts are similar to daily activities

5 Useful terms used in Programming Source code The actual text used to write the instructions for a computer program. This text is then translated into something meaningful the computer can understand. Compiler A software tool that translates source code into data that the computer can understand.

6 Useful terms used in Programming Data type The classification of pieces of information in a program. Typically, there are data types for integers (whole numbers), floating-point numbers (numbers with a decimal part), and single characters.

7 Useful terms used in Programming Variable A container which represents a value in a program. Variables can store different types of data including numeric values, single characters, and text strings. The value of a variable can change all throughout a program. Constant The same thing as a variable with one major difference - the value of a constant does not change, while the value of a variable can change all throughout a program.

8 8 Structured Programming Constructs Use only three constructs — sequence (statements, blocks) — selection (if, switch) — iteration (loops like while and for)

9 Activities Recipe Assembly instructions for a toy Map out the plan at amusement park A busy day schedule What is common to all of these?

10 Activities Recipe Assembly instructions for a toy Map out the plan at amusement park A busy day schedule What is common to all of these? SEQUENCE

11 Any valid expression terminated by a semicolon is a statement. Statements may be grouped together by surrounding them with a pair of curly braces { }. Such a group is syntactically equivalent to one statement and can be inserted where ever one statement is legal. Sequence

12 Such a group, known as a block, has one entry point (the first statement) and one exit point (the last statement). From now, whenever we mention statement, understand that you may substitute a block instead. Sequence

13 Activities Drive car or take DART bus? Party or study? Fly or drive? What is common to all of these?

14 Activities Drive car or take DART bus? Party or study? Fly or drive? What is common to all of these? DECISION

15 if (expression) statement1 else statement2 if and else are independent constructs, in that if can occur without else (but not the reverse). Selection (Decision)

16 “Guess The Number Game": (Suppose, these are the instructions for the robot to play me at the game) 1. Think of a random number between 1 and 1000 and don't tell me it. 2. Ask me to guess what the number is. Say "What is your Guess?". 3. Listen to my answer. 4. If my answer is less than the number you thought of, say "Too Small" and then GOTO step 2. 5. If my answer is more than the number you thought of, say "Too Big" and then GOTO step 2. 6. Say "Well Done! You got the right answer!" Example to write a Program


Download ppt "CS001 Introduction to Programming Day 2 Sujana Jyothi"

Similar presentations


Ads by Google