Class Notes (999,689)
US (389,922)
U of M (7,753)
ENGR (115)
ENGR 101 (104)
Lecture 7

ENGR 101 Lecture 7: Introduction C++

12 Pages
86 Views
Fall 2017

Department
Engineering
Course Code
ENGR 101
Professor
Jeffrey Ringenberg
Lecture
7

This preview shows pages 1-3. Sign up to view the full 12 pages of the document.
!"#$%&'()#&*+&,*-#&#)-.&/(01&2&.#3(,*'*)4&
-
!2,1&5$*6$23&.02$0.&/(01&7()07&2)-&89&2)-&#)-.&/(01&:4
-
;&,*35('#$&(.&2&5$*6$23&0120&0$2).'20#.&0*&*01#$&5$*6$23.&+$*3&1<32)=+$(#)-'%&
5$*6$23()6&'2)6<26#.&()0*&32,1()#&,*-#4&
-
>1#&+($.0&,*35('#$&/2.&-(.,*"#$#-&?%&@$2,#&A*55#$4&
-
B0.&)23#&2)-&(0.&0%5#&
§
B0&'#0.&01#&,*35('#$&C)*/&2?*<0&01#&"2$(2?'#.D
-
>1#&,*35('#$&5$#52$#.&3#3*$%&+*$&01#&"2$(2?'#4
-
>%5#&)23#G&
H2.(,&.%)02I&(.D
-
E*<&32%&5$*"(-#&2)&()(0(2'(J#$& #I5$#..(*)&+*$&2&-#,'2$20(*)4&
-
>%5#&)23#&K&#I5$#..(*)G
>1(.&,2)&?#&2&.()6'#&"2'<#9&?<0&(0&,2)&2'.*&?#&-#$("#-&+$*3&*01#$&"2$(2?'#.&*$&2)&2$?(0$2$%&
#I5$#..(*)4&
-
B+&%*<&-*)70&5$*"(-#&2)&()(0(2'(J#$9&01#&"2'<#&*+&01#&"2$(2?'#&(.&<)-#+()#-&<)0('&%*<&2..(6)&
.*3#01()6&()0*&(04&
-
>1#&0%5#&2&"2$(2?'#&,2)&1*'-&(.&+(I#-4&
LMM&(.&.020(,2''%&0%5#-4&
-
;&"2$(2?'#&,2)&5*0#)0(2''%&1*'-&2)%&"2'<#4&
N;>O;H&(.&-%)23(,2''%&0%5#-4&
-
P#+#$&0*&5$*5#$0(#.&*+&*<$&,*-#&0120&2$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%)02I
-
Z*$&'**5.&2$#&?#00#$&<.#-&/1#)&/#&12"#&2&C)*/&)<3?#$&*+&(0#$20(*).9&
-
P#2-()6&-202&+$*3&2&.0$#23&c
P#5'2,()6&0#I0&()&2&.0$()6&c
k1('#&'**5.&2$#&?#00#$&/1#)&/#&12"#&2)&<)C)*/)&)<3?#$&*+&(0#$20(*).&
-
Scope'
B.&01#&'(+#0(3#&*+&2&"2$(2?'#&
-
;&"2$(2?'#&6*#.&*<0&*+&.,*5#&20&01#&,'*.()6&:
-
Y2$(2?'#.&/(01&*)#&+<),0(*)&2$#&.#52$20#R()-#5#)-#)0&+$*3&"2$(2?'#.&/(01&01#&.23#&
)23#&()&2)*01#$&+<),0(*)&
-
You'cannot'return'multiple'values'from'a'function'in'C++.'The'only'way'to'do'it'is'with'
using'pass'by'reference.'
Nested'loops'$#+#$&0*&/1#)&'**5.&2$#&)#.0#-&/(01()&#2,1&*01#$&T2&'**5&/(01()&2&'**5U
Introduction*
k#-)#.-2%9& d,0*?#$&nX9&nj]W
oD]V&;N
!"#$%&'()#&*+&,*-#&#)-.&/(01&2&.#3(,*'*)4&
-
!2,1&5$*6$23&.02$0.&/(01&7()07&2)-&89&2)-&#)-.&/(01&:4
-
;&,*35('#$&(.&2&5$*6$23&0120&0$2).'20#.&0*&*01#$&5$*6$23.&+$*3&1<32)=+$(#)-'%&
5$*6$23()6&'2)6<26#.&()0*&32,1()#&,*-#4&
-
>1#&+($.0&,*35('#$&/2.&-(.,*"#$#-&?%&@$2,#&A*55#$4&
-
B0.&)23#&2)-&(0.&0%5#&
§
B0&'#0.&01#&,*35('#$&C)*/&2?*<0&01#&"2$(2?'#.D
E*<&2$#&$#F<($#-&0*&-#,'2$#&"2$(2?'#.&?#+*$#&%*<&,2)&<.#&01#34&
-
>1#&,*35('#$&5$#52$#.&3#3*$%&+*$&01#&"2$(2?'#4
-
>%5#&)23#G&
H2.(,&.%)02I&(.D
-
E*<&32%&5$*"(-#&2)&()(0(2'(J#$& #I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*&%*<&6#0&01#$#g
-
\&K&I&M&)G&RR&I&MK&)c
\&K&I&M&]G&RR&MMIc
B),$#3#)0D
-
\&K&I&=)&RR&I&=K)Gc
\&K&I&=]RR&==Ic
l#,$#3#)0D
-
L*)-(0(*)&=2)%&#I5$#..(*)&0120&,2)&?#&,*)"#$0#-&0*&2&?**'c
B+&T&,*)-(0(*)U&
-
For''**5.&+2''&()0*&2&.5#,(+(,&5200#$)9&01#%&#I#,<0#&2&?'*,C&*+&,*-#&2&+(I#-&)<3?#$&*+&
0(3#.D
-
Z*$&T()(0(2'(J#G&,*)-(0(*)G&(),$#3#)0U
-
b#3(,*'*).&2$#&<.#-&0*&.#52$20#&52$0.&*+&01#&+*$&'**5&
-
Z*$&'**5.&2)-&/1('#&'**5.&2$#&#F<("2'#)09&01#%&m<.0&12"#&-(++#$#)0&.%)02I
-
Z*$&'**5.&2$#&?#00#$&<.#-&/1#)&/#&12"#&2&C)*/&)<3?#$&*+&(0#$20(*).9&
-
P#2-()6&-202&+$*3&2&.0$#23&c
P#5'2,()6&0#I0&()&2&.0$()6&c
k1('#&'**5.&2$#&?#00#$&/1#)&/#&12"#&2)&<)C)*/)&)<3?#$&*+&(0#$20(*).&
-
Scope'
B.&01#&'(+#0(3#&*+&2&"2$(2?'#&
-
;&"2$(2?'#&6*#.&*<0&*+&.,*5#&20&01#&,'*.()6&:
-
Y2$(2?'#.&/(01&*)#&+<),0(*)&2$#&.#52$20#R()-#5#)-#)0&+$*3&"2$(2?'#.&/(01&01#&.23#&
)23#&()&2)*01#$&+<),0(*)&
-
You'cannot'return'multiple'values'from'a'function'in'C++.'The'only'way'to'do'it'is'with'
using'pass'by'reference.'
Nested'loops'$#+#$&0*&/1#)&'**5.&2$#&)#.0#-&/(01()&#2,1&*01#$&T2&'**5&/(01()&2&'**5U
Introduction*
k#-)#.-2%9& d,0*?#$&nX9&nj]W oD]V&;N
!"#$%&'()#&*+&,*-#&#)-.&/(01&2&.#3(,*'*)4&
-
!2,1&5$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#&2)&<)C)*/)&)<3?#$&*+&(0#$20(*).&
-
Scope'
B.&01#&'(+#0(3#&*+&2&"2$(2?'#&
-
;&"2$(2?'#&6*#.&*<0&*+&.,*5#&20&01#&,'*.()6&:
-
Y2$(2?'#.&/(01&*)#&+<),0(*)&2$#&.#52$20#R()-#5#)-#)0&+$*3&"2$(2?'#.&/(01&01#&.23#&
)23#&()&2)*01#$&+<),0(*)&
-
You'cannot'return'multiple'values'from'a'function'in'C++.'The'only'way'to'do'it'is'with'
using'pass'by'reference.'
Nested'loops'$#+#$&0*&/1#)&'**5.&2$#&)#.0#-&/(01()&#2,1&*01#$&T2&'**5&/(01()&2&'**5U
Introduction*
k#-)#.-2%9& d,0*?#$&nX9&nj]W oD]V&;N

Loved by over 2.2 million students

Over 90% improved by at least one letter grade.

Leah — University of Toronto

OneClass has been such a huge help in my studies at UofT especially since I am a transfer student. OneClass is the study buddy I never had before and definitely gives me the extra push to get from a B to an A!

Leah — University of Toronto
Saarim — University of Michigan

Balancing social life With academics can be difficult, that is why I'm so glad that OneClass is out there where I can find the top notes for all of my classes. Now I can be the all-star student I want to be.

Saarim — University of Michigan
Jenna — University of Wisconsin

As a college student living on a college budget, I love how easy it is to earn gift cards just by submitting my notes.

Jenna — University of Wisconsin
Anne — University of California

OneClass has allowed me to catch up with my most difficult course! #lifesaver

Anne — University of California
Description
Introduction Wednesday, October 25, 2017 9:13 AM Every line of code ends with a semicolon. Each program starts with int and {, and ends with }. A compiler is a program that translates to other programs from human friendly programing languages into machine code. The first compiler was discovered by Grace Hopper. You are required to declare variables before you can use them. It lets the compiler know about the variables: Its name and its type The compiler prepares memory for the variable. Basic syntax is: Type name; You may provide an initializer expression for a declaration. This can be a single value, but it can also be derived from other variables or an arbitrary expression. Type name = expression; If you dont provide an initializer, the value of the variable is undefined until you assign something into it.
More Less
Unlock Document
Start your 2 week free trial

Only pages 1-3 are available for preview. Some parts have been intentionally blurred.

Unlock Document
Start your 2 week free trial
You're Reading a Preview

Unlock to view full version

Unlock Document
Start your 2 week free trial

Share with your friends

Get 2 friends to sign-up for a free trial as well, and get an additional free week

Next

You've reached the limit of 4 previews this month

Create an account for unlimited previews.

Already have an account?

Log In


OR

Don't have an account?

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


OR

By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.


Submit