INC 161 , CPE 100 Computer Programming

Slides:



Advertisements
Similar presentations
For(int i = 1; i
Advertisements

What is shape function ? shape function is a function that will give the displacements inside an element if its displacement at all the node locations.
ALGORITHMS & FLOWCHARTING II
Introduction to working with Loops  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this course. Introduction to Computers and Programming.
Introducing Loop Statements Liang, pages Loop statements control repeated execution of a block of statements Each time the statements in the block.
Introduction to Computers and Programming Class 15 Introduction to C Professor Avi Rosenfeld.
CS 280 Data Structures Professor John Peterson. Big O Notation We use a mathematical notation called “Big O” to talk about the performance of an algorithm.
Flowchart Tutorial.
Writing algorithms using the for-statement. Programming example 1: find all divisors of a number We have seen a program using a while-statement to solve.
computer
End Show Writing a computer program involves performing the following tasks. 1. Understanding the problem 2. Developing an Algorithm for the problem 3.
Given an integer value stored in a variable, develop an algorithm to print the value to the display device. Integer Output Note that the value could be.
Review the following : Flowcharting Variable declarations Output Input Arithmetic Calculations Conditional Statements Loops.
Recursion Pepper. Another way to loop Call yourself repeatedly until you say to stop. Example: add up 10 numbers using addUp. -- Input – number to count.
ITP © Ron Poet Lecture 7 1 Repetition. ITP © Ron Poet Lecture 7 2 Easing Repetitive Tasks  Many computing task are repetitive.  Checking all known foods.
Exercise 3 Example> Write a C function that implements /* input : integer value n output : */ int f ( int n ) { int i, sum=0; for (i=1;i
Introduction to Computers and Programming Lecture 7:
Computer Programming A simple example /* HelloWorld: A simple C program */ #include int main (void) { printf (“Hello world!\n”); return.
Thinking about programming Intro to Computer Science CS1510 Dr. Sarah Diesburg.
PROBLEM SOLVING. REDBLUE GREENPINK ORANGEYELLOW Exit.
3:00. 2:59 2:58 2:57 2:56 2:55 2:54 2:53 2:52.
UCT Department of Computer Science Computer Science 1015F Iteration
Multiplication & Division
Introduction to Programming
INC 161 , CPE 100 Computer Programming
IGCSE 1 Cambridge Algorithms and flowcharts Unit 7 Computer Science
INC 161 , CPE 100 Computer Programming
Introduction to Programming
Unit VI- Selection – Making Decisions, Repetition
VISUAL BASIC .NET Chapter 3 Assignment Sheet
Computer Programming Flowchart.
Divisibility Rules Practice 2, 5, or 10?
Primitive Data, Variables, Loops (Maybe)
Thinking about programming
ALGORITHMS & FLOWCHARTING II
Top Fire Protection Services Ottawa available on Dubinskyconstruction
INC 161 , CPE 100 Computer Programming
INC 161 , CPE 100 Computer Programming
Searching CSCE 121 J. Michael Moore.
INC 161 , CPE 100 Computer Programming
✓ Task Planner for Division by chunking on a number line
INC 161 , CPE 100 Computer Programming
INC 161 , CPE 100 Computer Programming
Structured Program Design
INC 161 , CPE 100 Computer Programming
Introduction to Programming
Cs212: DataStructures Computer Science Department Lab 3 : Recursion.
Dr. Joe Anderson September 6, 2017
INC 161 , CPE 100 Computer Programming
INC 161 , CPE 100 Computer Programming
The ‘while’ loop ‘round and ‘round we go.
Introduction to Programming
Conditionals.
C Programming Getting started Variables Basic C operators Conditionals
INC 161 , CPE 100 Computer Programming
Unit 3 Review (Calculator)
INC 161 , CPE 100 Computer Programming
Introduction to Programming
Homework 2 (due:May 5th) Deadline : May 5th 11:59pm
What Task is Wasting Time
Exercise 5 1. We learned bubble sort during class. This problem requires you to modify the code for bubble sorting method to implement the selection sorting.
An ABC Book by.
The switch Statement When we want to compare a variable against several values to see which one it has, we can use the switch statement: switch (status)
Errors.
An ABC Book by.
An ABC Book by.
Calculate 9 x 81 = x 3 3 x 3 x 3 x 3 3 x 3 x 3 x 3 x 3 x 3 x =
CSCE 206 Lab Structured Programming in C
CHAPTER 1 THE ABC OF PROGRAMMING
Presentation transcript:

INC 161 , CPE 100 Computer Programming Lab 11

Task 1 #include <stdio.h> // Write you function here main() { int i = 2; increase(&i); printf(“i = %d”,i); } From the code given, write a function so that the program +2 and print i = 4. You must not change anything in main().

Task 2 #include <stdio.h> // Write you function here main() { int i = 2; i = increase(i); printf(“i = %d”,i); } From the code given, write a function so that the program +2 and print i = 4. You must not change anything in main().

Task 3 #include <stdio.h> // Write you function here main() { int a = 12, b = 16, c = 20, d; hcf(a,b,c,&d); printf(“HCF = %d”,d); } From the code given, write a function so that the program calculate the highest common factor (ห.ร.ม.) of a,b,c and get the result to d . You can assume that a,b,c are less than 1000

Write a flowchart first. e.g. a,b,c = 2,4,8 Assume start from 10 (for short) 2,4,8 is divisible by 10 – no 2,4,8 is divisible by 9 - no 2,4,8 is divisible by 8 - no 2,4,8 is divisible by 7 - no 2,4,8 is divisible by 6 - no 2,4,8 is divisible by 5 - no 2,4,8 is divisible by 4 - no 2,4,8 is divisible by 3 - no 2,4,8 is divisible by 2 – yes - >stop

Task 4 #include <stdio.h> // Write you function here main() { int a = 12, b = 16, c = 20, d; d = hcf(a,b,c); printf(“HCF = %d”,d); } From the code given, write a function so that the program calculate the highest common factor (ห.ร.ม.) of a,b,c and get the result to d . You can assume that a,b,c are less than 1000