انت هنا الان : شبكة جامعة بابل > موقع الكلية > نظام التعليم الالكتروني > مشاهدة المحاضرة
الكلية كلية العلوم
القسم قسم الكيمياء
المرحلة 2
أستاذ المادة بيادر عباس حسين الحميري
01/01/2019 15:51:14
EXAMPLE 3 Write an algorithm and draw a flowchart that will read the two sides of a rectangle and calculate its area. EXAMPLE 4 •Write an algorithm and draw a flowchart that will calculate the roots of a quadratic equation. • Hint: d = sqrt ( ), and the roots are: x1 = (–b + d)/2a and x2 = (–b – d)/2a DECISION STRUCTURES •The expression A>B is a logical expression •it describes a condition we want to test •if A>B is true (if A is greater than B) we take the action on left •print the value of A •if A>B is false (if A is not greater than B) we take the action on right •print the value of B
IF–THEN–ELSE STRUCTURE •The structure is as follows If condition then true alternative else false alternative endif •The algorithm for the flowchart is as follows: If A>B then print A else print B endif 5 RELATIONAL OPERATORS EXAMPLE 5 •Write an algorithm that reads two values, determines the largest value and prints the largest value with an identifying message. ALGORITHM Step 1: InputVALUE1, VALUE2 Step 2: if (VALUE1 > VALUE2) then NESTED IFS •One of the alternatives within an IF–THEN–ELSE statement •may involve furtherIF–THEN–ELSE statement EXAMPLE 6 •Write an algorithm that reads threenumbers and prints the value of the largest number. else endif Step 3: Print “The largest value is”, MAX Exercise: •Flowchart: Draw the flowchart of the above Algorithm.
المادة المعروضة اعلاه هي مدخل الى المحاضرة المرفوعة بواسطة استاذ(ة) المادة . وقد تبدو لك غير متكاملة . حيث يضع استاذ المادة في بعض الاحيان فقط الجزء الاول من المحاضرة من اجل الاطلاع على ما ستقوم بتحميله لاحقا . في نظام التعليم الالكتروني نوفر هذه الخدمة لكي نبقيك على اطلاع حول محتوى الملف الذي ستقوم بتحميله .
الرجوع الىلوحة التحكم
|