1.5 Conditional Statements academy.zariba.com 1. Lecture Content 1.If-else statements 2.If-else-if statements 3.Switch-case statements 2.

Slides:



Advertisements
Similar presentations
If Statements & Relational Operators Programming.
Advertisements

Lecture 4 More Examples of Karnaugh Map. Logic Reduction Using Karnaugh Map Create an Equivalent Karnaugh Map Each circle must be around a power of two.
If Statements. COMP104 If / Slide 2 Three Program Structures * Sequence - executable statements which the computer processes in the given order * Choice.
Lecture 11. Today’s topic Conditional statement –Relational operators –if statement –if-else statement –If-elseif statement.
CS 3850 Lecture 5 Operators. 5.1 Binary Arithmetic Operators Binary arithmetic operators operate on two operands. Register and net (wire) operands are.
1.9 Methods academy.zariba.com 1. Lecture Content 1.What is a method? Why use methods? 2.Void Methods and methods with parameters 3.Methods which return.
Selection. Computer Programming 2 Objectives Examine if statement in more detail Study use of switch statement to implement multialternative selections.
Lecture Review (If-else Statement) if-else statement has the following syntax: if ( condition ) { statement1; } else { statement2; } The condition.
1.10 Strings academy.zariba.com 1. Lecture Content 1.What is a string? 2.Creating and Using strings 3.Manipulating Strings 4.Other String Operations 5.Building.
Section 3 - Selection and Repetition Constructs. Control Structures 1. Sequence 2. Selection 3. Repetition.
1.7 Arrays academy.zariba.com 1. Lecture Content 1.Basic Operations with Arrays 2.Console Input & Output of Arrays 3.Iterating Over Arrays 4.List 5.Cloning.
10.6 Equations of a Circle Standard Equation of a Circle Definition of a Circle.
Implementing Control Logic in C# Svetlin Nakov Telerik Corporation
Today’s Lecture  Boolean Expressions  Building, Evaluating & Precedence Rules  Branching Mechanisms  if-else  switch  Nesting if-else  Loops  While,
Python – Making Decisions Lecture 02. Control Structures A program that only has one flow is useful but limited. We can use if statements to make these.
Decision Structures Chapter 4 Part 2. Chapter 4 Objectives To understand o What relational operators are and how they are used o Boolean logic o Testing.
Prime Factor and GCF. Vocab Prime number - # > 1 whose factors are only 1 and itself Composite number - # > 1 that has more than 2 factors Prime factorization.
1.6 Loops academy.zariba.com 1. Lecture Content 1.While loops 2.Do-While loops 3.For loops 4.Foreach loops 5.Loop operators – break, continue 6.Nested.
1.3 Console Input And Output academy.zariba.com 1.
Conditional Statements Implementing Control-Flow Logic in C# SoftUni Team Technical Trainers Software University
PAGES:51-59 SECTION: CONTROL1 : DECISIONS Decisions.
Basic Of Computer Science
Lecture-2 Operators and Conditionals. Variables(again???) Type: Representation of “bits” in memory Variables: Name for a memory object. Starts with letters,
CONTROL STRUCTURE The if, elseif, and else & switch Statements 1.
Chapter 6: Control Structures Computer Programming Skills Second Term Department of Computer Science Foundation Year Program Umm Alqura.
Liang, Introduction to Programming with C++, Second Edition, (c) 2010 Pearson Education, Inc. All rights reserved Chapter 3 Selections.
Writing Program Code in BASIC Write a program to prompt for and accept values into TWO variables, numx and numy. The program should square the value stored.
PROBLEM SOLVING & ALGORITHMS CHAPTER 5: CONTROL STRUCTURES - SELECTION.
1 COMS 261 Computer Science I Title: C++ Fundamentals Date: September 21, 2005 Lecture Number: 10.
If…else statements. Boolean Expressions Boolean expression - An expression whose value is either true or false true = 1 false = 0 Datatype: boolean.
Perform Calculations and Control Flow Telerik Software Academy Learning & Development Team.
Adding Integers. Zero Pair = 0 Why it works… __________ Property says you can add or subtract zero without changing the value of an expression.
Decisions  Relational operators  Operate on two numbers or two Strings  ==, !=, >, >=,
Liang, Introduction to C++ Programming, (c) 2007 Pearson Education, Inc. All rights reserved X1 Chapter 3 Control Statements.
COMP Flow of Control: Branching 1 Yi Hong May 19, 2015.
Selection Sort Comparison Data Movement Sorted.
Chapter 4 Control Structures: Selection We introduced the three fundamental control structures from which all programs are developed: 1. Sequence structures.
Conditionals Opening Discussion zWhat did we talk about last class? zDo you have any questions about the assignment? zPass by value limitations.
If Statements Programming. COMP104 Lecture 7 / Slide 2 Review: Rules for Division l C++ treats integers different than doubles. 100 is an int. l 100.0,
Control statements Mostafa Abdallah
1.2 Primitive Data Types and Variables
LESSON 4 Decision Control Structure. Decision Control Structures 1. if statement 2. if-else statement 3. If-else-if statement 4. nested if statement 5.
Interduction to MATLAB (part 2) Manal Alotaibi Mathematics department College of science King saud university.
The If Statement There are no switch statements in Python. You need to use just if statements. There are no switch statements in Python. You need to use.
Applied Algebra B Lesson: 2 – 3 Adding Integers Objective: Learn to add integers.
1.8 Multidimensional Arrays academy.zariba.com 1.
Implementing Control Logic in C# Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical trainer
Algebra 1. A = 0 B = 8.99 C = 1 D. 1(7.99) = 7.99.
Introduction to JavaScript academy.zariba.com 1. Lecture Content 1.What is JavaScript? 2.JavaScript Pros and Cons 3.The weird JavaScript stuff 4.Including.
Introduction to programming in java Lecture 11 Boolean Expressions and Assignment no. 2.
Building Java Programs
Lab Instructor: Salem Othman
2.2 Defining Classes Part 2 academy.zariba.com.
Chapter 4: Control Structures
JavaScript OOP academy.zariba.com.
SELECTION STATEMENTS (1)
Building Java Programs
Structured Program Development in C
Counting & Comparing Money 2 $ $ $ $.
Counting & Comparing Money $ $ $ $.
C# Basics These slides are designed for Game Design Class
Pages:51-59 Section: Control1 : decisions
Computer Science Core Concepts
Every number has its place!
Building Java Programs
Question 1a) What is printed by the following Java program? int s;
Pages:51-59 Section: Control1 : decisions
Inequalities and their Graphs
Solving inequalities Chapter 3.
Building Java Programs
Presentation transcript:

1.5 Conditional Statements academy.zariba.com 1

Lecture Content 1.If-else statements 2.If-else-if statements 3.Switch-case statements 2

Comparison Operators 3 OperatorNotation Equals== Not Equals!= Greater Than> Greater Than or Equals>= Less Than< Less Than or Equals<=

Logical Operators 4 OperatorNotation Not! And&& Or|| XOr^

1. If-else and if-else-if Statments 5

2. Switch Case statements 6

Homework 7 1.Write an if statement that exchanges the values of 2 numbers if the first is bigger than the second 2.Write a program that finds the largest of 3 integers, using if statements. 3.Sort 3 integer numbers using if statements. 4.Write a program that enters a number from 10 to 19 and prints on the console the name of the number. E.g. 11 – “eleven”. Use switch. 5.Write a boolean expression for finding if the bit 2 (counting from 0) of a given integer is 1 or 0. 6.Write an expression that checks if a given point (x,y) is within a circle with radius 4 and centre at (0,0) 7.*We are given 5 integer numbers. Write a program that checks if there is a subset of these 5 numbers which sums to zero. List all such sums. E.g. 5,0,-2,-3,1 should print 1.) 0 =0 2.) 5-2-3=0.

8 References

9 Zariba Academy Questions