×

### Let's log you in.

or

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

×

or

by: awright

31

0

5

# ECE 118 Notes ECE 118

awright
UM
GPA 3.9

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

×
Unlock Preview

Notes from January
COURSE
Intro to Programming Languages
PROF.
Kubat
TYPE
Class Notes
PAGES
5
WORDS
KARMA
25 ?

## Popular in Computer Science and Engineering

This 5 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 31 views. For similar materials see Intro to Programming Languages in Computer Science and Engineering at University of Miami.

×

## Reviews for ECE 118 Notes

×

×

### 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
1.27.2016 Notes Review #include "library.h" void main() { print((8*5 +2.0)/5); } This prints 8.4 because the minute you put 2.0 instead of 2, the whole thing becomes double and  it’s capable of calculating/printing decimals. 1. #include "library.h" void main() { print((1234-1222)*100); } 2. #include "library.h" void main() { print((1234/100)*100); } 3. #include "library.h" void main() { print(1234 - 1234%100); } All of the above three functions print 1200 as the result. They are methods of rounding. If (~~~) Sets up a condition that will cause the next thing to happen if satisfied Else ~~~ Command that follows “if condition” if the “if condition” is not satisfied If­Else Conditions #include "library.h" void main() { int const x = 4; int const y = 2; if (x>y) print("x is greater than y"); else print("x is NOT greater than y"); } With this program and the current integer settings, the result is printed “x is greater than y”  because the If Condition is satisfied #include "library.h" void main() { int const x = 2; int const y = 4; if (x>y) { print ("x is greater than y"); new_line(); print("indeed it is"); new_line(); } else { print("x is NOT greater than y"); new_line(); print("no, it is really not"); new_line(); } } Everything between the inner {} is interpreted as one function so if the If Condition is satisfied,  then EVERYTHING between the {} under the If Condition occurs. Same goes for the Else  Condition if, like in this program, it is satisfied. So this prints “x is NOT greater than y/no, it is  really not.” #include "library.h" void main() { int const x = 4; int const y = 4; if (x>y) { print ("x is greater than y"); new_line(); print("indeed it is"); new_line(); } else (y>x) { print("x is NOT greater than y"); new_line(); print("no, it is really not"); new_line(); } } In this one, nothing occurs because neither the If Condition nor the Else Condition are satisfied.  4=4 and one is not greater than the other. #include "library.h" void main() { int const x = 4; int const y = 4; if (x>y) { print ("x is greater than y"); new_line(); print("indeed it is"); new_line(); } else (y>x) { print("x is NOT greater than y"); new_line(); print("no, it is really not"); new_line(); } else print ("don't be silly, they are equal"); } This is how you fix that problem, by tacking another else. So as you can see, else sometimes has  a condition after it, and sometimes it doesn’t and just occurs if none of the other ifs or elses are  satisfied. Which is Greater #include "library.h" void which_is_greater(int const a, int const b) { if (a>b) print(a); else print(b); } void main() { int const x = 4; int const y = 4; which_is_greater(x,y); } This is a program that can determine which is greater. Use void for the first function because you are not trying to return something, you are trying to print something. If you want to change it so  that you use int instead of void, then you have to print something in the main and add return in a  couple places as follows. #include "library.h" int which_is_greater(int const a, int const b) { if (a>b) return(a); else return(b); } void main() { int const x = 4; int const y = 4; print (which_is_greater(x,y)); } >  Greater than < Less than >= Greater than or equal to <= Less than or equal to == Equal to != Not equal Greater Than or Equal To #include "library.h" void main() { int const x = 4; int const y = 4; if (x >= y) print("x is not smaller"); new_line(); } The > or < must always come before the = for it to be effective. Equal to #include "library.h" void main() { int const x = 4; int const y = 4; if (x == y) print("x is not smaller"); new_line(); } Use two equal signs because one equal sign means switch one thing for another. Two equal signs (==) is checking for equality. Not Equal To #include "library.h" void main() { int const x = 4; int const y = 1; if (x != y) print("x and y are equal"); new_line(); } The exclamation point and the equal sign mean not equal. bool const ~ Can be set equal to true or false Bool Const #include "library.h" void main() { int const x = 4; int const y = 1; bool const b = true; if (b) print("it is true"); new_line(); } Because the bool const is true (x is indeed greater than y) so it prints it is true.

×

×

### BOOM! Enjoy Your Free Notes!

×

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."

Jennifer McGill UCSF Med School

#### "Selling my MCAT study guides and notes has been a great source of side revenue while I'm in school. Some months I'm making over \$500! Plus, it makes me happy knowing that I'm helping future med students with their MCAT."

Bentley McCaw University of Florida

#### "I was shooting for a perfect 4.0 GPA this semester. Having StudySoup as a study aid was critical to helping me achieve my goal...and I nailed it!"

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