1 / 83

Ch6b

Ch6b. // File: prob0616.cpp // Computer Systems // Problem 6.16 #include <iostream> using namespace std; int myAge ; void putNext ( int age) { int nextYr ; nextYr = age + 1; cout << "Age: " << age << endl ; cout << "Age next year: " << nextYr << endl ; } int main () {

karli
Download Presentation

Ch6b

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Ch6b

  2. // File: prob0616.cpp // Computer Systems // Problem 6.16 #include <iostream> using namespace std; intmyAge; void putNext (int age) { intnextYr; nextYr = age + 1; cout << "Age: " << age << endl; cout << "Age next year: " << nextYr << endl; } int main () { cin >> myAge; putNext (myAge); putNext (64); return 0; }

  3. Problem 6.16 0000 040024 BR main 0003 0000 myAge: .BLOCK 2 ;global varaible #2d ; ;******* void putNext (int age) age: .EQUATE 4 ;formal parameter #2d nextYr: .EQUATE 0 ;local variable #2d 0005 680002 putNext: SUBSP 2,i ;allocate #nextYr 0008 C30004 LDA age,s ;nextYr = age + 1 000B 700001 ADDA 1,i 000E E30000 STA nextYr,s 0011 410046 STRO msg1,d ;cout << "Age: " 0014 3B0004 DECO age,s ; << age 0017 50000A CHARO '\n',i ; << endl 001A 41004C STRO msg2,d ;cout << Age next year: " 001D 3B0000 DECO nextYr,s ; << nextYr 0020 50000A CHARO '\n',i ; << endl 0023 5A RET2 ;deallocate #nextYr, pop retAddr

  4. inta,b; • void swap(int&r, int& s) { • int temp; • temp = r; • r = s; • s = temp; } • void order (int &x, int& y) { • If (x < y) { • swap(x,y); } }//ra2 • int main() { • … • order(a,b); • cout ….

More Related