Download presentation
Presentation is loading. Please wait.
Published byMarvin Washington Modified over 9 years ago
1
Lecture 2 Examples Pseudo code and flowcharts
2
Problem 1 Read a number as input and then print if it is even or odd
3
Problem 1 : Flowchart and pseudo code Pseudo code: read number get the remainder when the number is divided by 2 if remainder is 0 print “number is even” else print “number is odd”
4
Problem 2 Read the radius of circle and print the area and circumference only if the value of the radius is more than zero.
5
Problem 2 Pseudo code: read radius if radius <= 0 print “Radius cannot be negative or zero” exit if radius > 0 calculate area calculate circumference print area print circumference
6
Problem 3 Take two numbers as input and print the greater of the two. If numbers are equal print “numbers are equal”.
7
Problem 3 Pseudo code: read n1, n2 if n1 equals n2 print “numbers are equal” exit if n1 > n2 print “n1 is greater” else print “n2 is greater”
8
Problem 4 Read the length of the three sides of a triangle and print if it the triangle is an equilateral or isosceles or scalene triangle. equilateral – all sides are equal isosceles – any two sides are equal scalene – all sides have different length Try this problem as an exercise and show it to me in the labs
9
Quiz 1 Next week at this lecture time 45 mins, 5% of the course Lecture 1 + Lecture 2 part (what we did today) MCQs, short answer, flowcharts, pseudo code and c++ programs
10
Lab talk DevC++ is already setup for most of you Always come to lab with the lecture printout or PPT Lab exercises are related directly to lecture and are the practical part of the lecture YOU MUST TRY TO SOLVE THE LAB EXERCISES BEFORE YOU COME TO LAB – TRY! Save and organize your C++ programs into folders like lab 1, lab 2 – you will need them later…. There are lab exams also.. later Lab exercises always available on the website a couple of days before the lab
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.