×

Let's log you in.

or

Don't have a StudySoup account? Create one here!

×

or

1 review
by: awright

44

1

3

Notes for ECE 118 ECE 118

awright
UM
GPA 3.9

Get a free preview of these Notes, just enter your email below.

×
Unlock Preview

Notes from the week of February 1, 2016
COURSE
Intro to Programming Languages
PROF.
Kubat
TYPE
Class Notes
PAGES
3
WORDS
KARMA
25 ?

1

1 review
"Almost no time left on the clock and my grade on the line. Where else would I go? Andrea has the best notes period!"
Mr. Bridgette Kuvalis

Popular in Computer Science and Engineering

This 3 page Class Notes was uploaded by awright on Sunday February 28, 2016. The Class Notes belongs to ECE 118 at University of Miami taught by Kubat in Fall 2015. Since its upload, it has received 44 views. For similar materials see Intro to Programming Languages in Computer Science and Engineering at University of Miami.

×

Reviews for Notes for ECE 118

Almost no time left on the clock and my grade on the line. Where else would I go? Andrea has the best notes period!

-Mr. Bridgette Kuvalis

×

×

What is Karma?

You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 02/28/16
2.1.2016 Notes Upper Bound Smaller than Lower Bound #include "library.h" int sums(int const n) { if (n>0) return (n + sums(n-1)); else return(0); } int sums(int const n, int const m) { if(n==m) return(n); else return(m + sums(n, m-1)); } void main() { int const n = 3; int const m = 1; print("the sum is "); print(sums(n, m)); new_line(); } What will happen if we use n=3 and m=1 in this recursion program from the last class? How can  we stop it from malfunctioning? #include "library.h" int sums(int const n) { if (n>0) return (n + sums(n-1)); else return(0); } int sums(int const n, int const m) { if(n>m) return(sums(m,n)); if (n==m) return(n); else return(m + sums(n, m-1)); } void main() { int const n = 3; int const m = 1; print("the sum is "); print(sums(n, m)); new_line(); } This will fix it because it tells the program to do the reverse and the compiler will ignore it but  not report an error or anything. It’s just another assurance to throw in to deal with that possible  problem. It’s “grammatically” correct but harmless. If you were going to make a square for say a quiz, use m*m instead of m^2. You can use the  above pattern to do so along with many other possible things. Prints a Set of Points #include "library.h" void draw_a_set_of_points(int const x, int const y, int const n, int const d) { if (n>0) { move_to(x,y); draw_point(); draw_a_set_of_points(x+d,y,n-1,d); } } void main() { make_window(500, 400); set_pen_width(3); draw_a_set_of_points(100,100,20,5); } For this you use void and don’t return anything to recursively draw a picture. This is because  you’re not trying to return a value, you’re just repeating an act over and over again. You call  draw_a_set_of_points recursively to create the line. X, y is where the line starts, n is how many  dots you want, and d is the distance you want between the dots. Draws Any Shape with Recursion #include "library.h" void line_and_turn(int const N, int const side, int const angle) { if (N>0) { draw_distance(side); turn_right_by_degrees(angle); line_and_turn(N-1,side,angle); } } void main() { make_window(500, 400); set_pen_width(3); move_to(100,100); int const N=6; line_and_turn(N,50,360/N); } Given a number of sides, this program calculates the angle necessary and draws a shape by  creating N number of lines and turning the calculated angle to make the shape. It keeps going  until it runs out of sides by reducing N to zero. If you increase to N=40 and then the side=10,  you end up with a circle (the numbers are flexible). Drawing a Circle with Recursion and Previous Line Drawing #include "library.h" void line_and_turn(int const N, int const side, int const angle) { if (N>0) { draw_distance(side); turn_right_by_degrees(angle); line_and_turn(N-1,side,angle); } } void draw_circle(int const x, int const y, double radius) { move_to(x,y); int const N = 360; int const side = (2*3.14*radius)/N; int const angle = 360/N; line_and_turn(N,side,angle); } void main() { make_window(500, 400); set_pen_width(3); move_to(100,100); int const radius = 100; int const x = 100; int const y = 100; draw_circle(x,y,radius); }

×

25 Karma

×

×

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

Why people love StudySoup

Jim McGreen Ohio University

"Knowing I can count on the Elite Notetaker in my class allows me to focus on what the professor is saying instead of just scribbling notes the whole time and falling behind."

Anthony Lee UC Santa Barbara

"I bought an awesome study guide, which helped me get an A in my Math 34B class this quarter!"

Jim McGreen Ohio University

"Knowing I can count on the Elite Notetaker in my class allows me to focus on what the professor is saying instead of just scribbling notes the whole time and falling behind."

Parker Thompson 500 Startups

"It's a great way for students to improve their educational experience and it seemed like a product that everybody wants, so all the people participating are winning."

Become an Elite Notetaker and start selling your notes online!
×

Refund Policy

STUDYSOUP CANCELLATION POLICY

All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email support@studysoup.com

STUDYSOUP REFUND POLICY

StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here: support@studysoup.com

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to support@studysoup.com