Lecture Introduction to computer and programming - Lecture No 4

After studying this lecture you will be able to understand: Development process model, software development process activities, requirement for a web development process model, rational unified process model (RUP), suitability for web application development. | CSC103: Introduction to Computer and Programming Lecture No 4 Today’s lecture outline Complex flowcharts Function Algorithm A simple C program Make a flowchart to fill the bath tub with water Start End Turn on hot and cold water Too hot or cold Adjust hot and cold taps Wait for 2 minutes Is the bath full A A Turn off hot and cold taps Y N N Y Turn on the hot and cold taps. Is it too hot or cold? If it is, go to step 3, otherwise go to step 4. Adjust the hot and cold taps and go back to step 2. Wait for 2 minutes. Is the bath tub full? If it is, go to step 6, otherwise go to step 4. Turn off the hot and cold taps. Make a flowchart to find the input number is greater than 100 or less than or equal to 100 Start End Display message “Enter a number” Read the input in x Is x > 100 if it is go to step 4 otherwise go to step 5 Display a message “Greater than 10” Display a message “Less than or equal to 100” Input: x Display: Enter a number x > 100 False True Display: Greater than 100 Display: less than or equal to 100 Functions From a programming perspective, functions allow you to group a logical series of activities, or program statements, under one name. Every C program must have a main function For example, suppose I want to create a function called bakeCake Algorithms An algorithm is a finite step-by-step process for solving a problem. It can be as simple as a recipe to bake a cake, or as complicated as the process to implement an autopilot system for a 747 jumbo jet. Algorithms generally start off with a problem statement. It is this problem statement that programmers use to formulate the process for solving the problem. Algorithm for BakeCake Mix wet ingredients in mixing bowl Combine dry ingredients Spoon batter into greased baking pan Bake cake at 350 degrees for 30 minutes Anyone reading my code will see my function called bakeCake and know right away that I’m trying to bake cakes. Functions Functions are typically not static, meaning they are living entities, . | CSC103: Introduction to Computer and Programming Lecture No 4 Today’s lecture outline Complex flowcharts Function Algorithm A simple C program Make a flowchart to fill the bath tub with water Start End Turn on hot and cold water Too hot or cold Adjust hot and cold taps Wait for 2 minutes Is the bath full A A Turn off hot and cold taps Y N N Y Turn on the hot and cold taps. Is it too hot or cold? If it is, go to step 3, otherwise go to step 4. Adjust the hot and cold taps and go back to step 2. Wait for 2 minutes. Is the bath tub full? If it is, go to step 6, otherwise go to step 4. Turn off the hot and cold taps. Make a flowchart to find the input number is greater than 100 or less than or equal to 100 Start End Display message “Enter a number” Read the input in x Is x > 100 if it is go to step 4 otherwise go to step 5 Display a message “Greater than 10” Display a message “Less than or equal to 100” Input: x Display: Enter a number x > 100 False True Display: Greater than 100 Display:

Bấm vào đây để xem trước nội dung
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.