L AB 4 July 5th. F OR LOOP Exercise 1: Find two ways of “Summing all 1, 2, and 3 digit prime numbers.” Use for loop Hint: isprime, primes.

Slides:



Advertisements
Similar presentations
2.3 Modeling Real World Data with Matrices
Advertisements

MIMO systems. Interaction of simple loops Y 1 (s)=p 11 (s)U 1 (s)+P 12 (s)U 2 (s) Y 2 (s)=p 21 (s)U 1 (s)+p 22 (s)U 2 (s) C1 C2 Y sp1 Y sp2 Y1Y1 Y2Y2.
CS107 Introduction to Computer Science Lecture 3, 4 An Introduction to Algorithms: Loops.
AB 11 22 33 44 55 66 77 88 99 10  20  19  18  17  16  15  14  13  12  11  21  22  23  24  25  26  27  28.
1. What number does the following array represent?
Nested Loops. Problem Print The only printfs you can use are: –printf(“*”); –printf(“\n”); *****
Exercise Exercise3.1 8 Exercise3.1 9 Exercise
Lecture 14 Go over midterm results Algorithms Efficiency More on prime numbers.
11.3 Function Prototypes A Function Prototype contains the function’s return type, name and parameter list Writing the function prototype is “declaring”
11-1 Chapter 11 2D Arrays Asserting Java Rick Mercer.
Exercise Exercise Exercise Exercise
Exercise Exercise Exercise Exercise
Exercise Exercise6.1 7 Exercise6.1 8 Exercise6.1 9.
Chapter seven review. What is the output of: Private Sub cmdButton_Click() Dim i As Integer, a(1 To 4) As integer Open "DATA.TXT" For Input As #1 For.
Презентація за розділом “Гумористичні твори”
Центр атестації педагогічних працівників 2014
Галактики і квазари.
Характеристика ІНДІЇ.
Процюк Н.В. вчитель початкових класів Боярської ЗОШ І – ІІІ ст №4
Arrays. What is the output of: Private Sub cmdButton_Click() Dim i As Integer, a(1 To 4) As integer Open "DATA.TXT" For Input As #1 For i = 1 To 4 Input.
JavaScript with Input & Output Step 1: Use tags JavaScript Template.
Lecture 7 Sept 29 Goals: Chapters 5 and 6. Chapter 5 - Exercises Exercise 5.2. Write a script swap.m that swaps the values of variables a and b. For example:
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.
COM S 207 While-Loop Statement Instructor: Ying Cai Department of Computer Science Iowa State University
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Looping Exercises Deciding Which Loop to Use At this.
Loop Exercise 1 Suppose that you want to take out a loan for $10,000, with 18% APR, and you're willing to make payments of $1,200/month. How long will.
Excel VBA TOM VORVES DO THE ACTIVITY EXERCISE ON PAGE 53 IF YOU WISH ElaineNikky JennArrinMylinh Matt Move Row.
Textbook Problem Java – An Introduction to Problem Solving & Programming, Walter Savitch, pp.219, Problem 08.
1 What We Will Learn  Introduction  Passing input parameters  Producing output  Scope of variables  Storage Class of variables  Function usage example.
Array Cs212: DataStructures Lab 2. Array Group of contiguous memory locations Each memory location has same name Each memory location has same type a.
WEEK 4 Class Activities Lecturer’s slides.
More While Loop Examples CS303E: Elements of Computers and Programming.
Count and add list of numbers From user input and from file.
Data Structure CS 322. What is an array? Initializing arrays Accessing the values of an array Multidimensional arrays LAB#1 : Arrays.
Духовні символи Голосіївського району
CS1109 L AB 3 July 3rd. R OAD M AP Homework submission Review How to use function and scripts While-end Finish last exercise Lab 2 Challenge questions.
Homework #2: Functions and Arrays By J. H. Wang Mar. 24, 2014.
Arrays What is an array… –A data structure that holds a set of homogenous elements (of the same type) –Associate a set of numbers with a single variable.
For loop. Exercise 1 Write a program to have the user input three (3) numbers: (f)rom, (t)o, and (i)ncrement. Count from f to t in increments of i, inclusive.
General Condition Loop A general condition loop just loops while some condition remains true. Note that the body of the loop should (eventually) change.
Nested Loops CS303E: Elements of Computers and Programming.
Exercise 24 ÷ 2 12.
A Number as a Product of Prime Numbers
Python I/O.
Counting Loops.
CSCE 206 Lab Structured Programming in C
Class Examples.
Проф. д-р Васил Цанов, Институт за икономически изследвания при БАН
ЗУТ ПРОЕКТ на Закон за изменение и допълнение на ЗУТ
О Б Щ И Н А С И Л И С Т Р А П р о е к т Б ю д ж е т г.
Електронни услуги на НАП
Боряна Георгиева – директор на
РАЙОНЕН СЪД - БУРГАС РАБОТНА СРЕЩА СЪС СЪДЕБНИТЕ ЗАСЕДАТЕЛИ ПРИ РАЙОНЕН СЪД – БУРГАС 21 ОКТОМВРИ 2016 г.
Сътрудничество между полицията и другите специалисти в България
Съобщение Ръководството на НУ “Христо Ботев“ – гр. Елин Пелин
НАЦИОНАЛНА АГЕНЦИЯ ЗА ПРИХОДИТЕ
ДОБРОВОЛЕН РЕЗЕРВ НА ВЪОРЪЖЕНИТЕ СИЛИ НА РЕПУБЛИКА БЪЛГАРИЯ
Съвременни софтуерни решения
ПО ПЧЕЛАРСТВО ЗА ТРИГОДИШНИЯ
от проучване на общественото мнение,
Васил Големански Ноември, 2006
Програма за развитие на селските райони
ОПЕРАТИВНА ПРОГРАМА “АДМИНИСТРАТИВЕН КАПАЦИТЕТ”
БАЛИСТИКА НА ТЯЛО ПРИ СВОБОДНО ПАДАНЕ В ЗЕМНАТА АТМОСФЕРА
МЕДИЦИНСКИ УНИВЕРСИТЕТ – ПЛЕВЕН
Стратегия за развитие на клъстера 2015
Моето наследствено призвание
Правна кантора “Джингов, Гугински, Кючуков & Величков”
Безопасност на движението
CSCE 206 Lab Structured Programming in C
Presentation transcript:

L AB 4 July 5th

F OR LOOP Exercise 1: Find two ways of “Summing all 1, 2, and 3 digit prime numbers.” Use for loop Hint: isprime, primes

F OR LOOP

C ONVERT THE F OR LOOP TO W HILE LOOP Exercise 2:

C ONVERT THE F OR LOOP TO W HILE LOOP

F OR LOOP Exercise 3: Duplicate each element in an array Input: Array [1,2,3,4] Output: Array [1,1,2,2,3,3,4,4]

C HALLENGE Q UESTION : N ESTED L OOPS Exercise 4 Printing Out rows of Stars Ask the user for how many rows

C HALLENGE Q UESTION : N ESTED L OOPS