Concept explainers
Consider the following skeletal C program:
void fun1(void); /* prototype */
void fun2(void); /* prototype */
void fun3(void); /* prototype */
void main() {
int a, b, c;
. . .
}
void fun1(void) {
int b, c, d;
. . .
}
void fun2(void) {
int c, d, e;
. . .
}
void fun3(void) {
int d, e, f;
. . .
}
Given the following calling sequences and assuming that dynamic scoping is used, what variables are visible during execution of the last function called? Include with each visible variable the name of the function in which it was defined.
- a. main calls fun1; fun1 calls fun2; fun2 calls fun3.
- b. main calls fun1; fun1 calls fun3.
- c. main calls fun 2; fun2 calls fun3; fun3 calls fun1.
- d. main calls fun 3; fun 3 calls fun l.
- e. main, calls fun 1; fun 1 calls fun 3; fun 3 calls fun 2.
- f. main calls fun 3; fun 3 calls fun 2; Calls fun 1.
Want to see the full answer?
Check out a sample textbook solutionChapter 5 Solutions
Concepts Of Programming Languages
Additional Engineering Textbook Solutions
Starting out with Visual C# (4th Edition)
Starting Out with Java: From Control Structures through Objects (6th Edition)
Modern Database Management (12th Edition)
Programming in C
Starting Out with Python (3rd Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
- Java code; object oriented program; private static void Togrid(source s) { grid g1 = new grid("s"); grid g2= new grid("between"); layout b= new layout("press"); s.addObject(g1);s.addObject(g2);s.addObject(b); Using above test program(is added after following feature is implanted); How to write a code of instance method type void with parameter of "Source s" that adds object into array. public void addObject(Source c){} Using above method, how to code an instance method of type Object[] without parameter that returns new array with object that was added into array. public Object[] getObject(){}arrow_forwardExplain this java codes private void put(int cell,int player) { int i=-1,j=-1;; switch(cell) { case 1:i=2;j=0;break; case 2:i=2;j=1;break; case 3:i=2;j=2;break; case 4:i=1;j=0;break; case 5:i=1;j=1;break; case 6:i=1;j=2;break; case 7:i=0;j=0;break; case 8:i=0;j=1;break; case 9:i=0;j=2;break; default:display(overridegrid);return; } char mark='x'; if(player==0) mark='o'; grid[i][j]=mark; display(grid); } private int startGame() { init(); display(grid); int status=playingid; while(status==playingid) { put(playerMove(),0); if(override==1) { System.out.println("O wins."); return playerid; } status=checkForWin(); if(status!=playingid) break; try{Thread.sleep(1000);}catch(Exception e){System.out.print(e.getMessage());} put(compMove(),1); status=checkForWin(); } return status; } private void init() { movesPlayer=""; override=0; marks=new int[8][6]; wins=new int[][] //new int[8][3]; weights=new int[]{3,2,3,2,4,2,3,2,3}; grid=new…arrow_forwardFill in the blanks (...)C++ homework #include <iostream>using namespace std;class Date {public:….. void setDate(int date_day, int date_month, int date_year){ //put the date……………….} void getDate(){//show the date………}}; // end class //... int main(){int day,month,year; cout<<"Please enter the currents day, month and year"<<endl;cout <<"enter day: ";cin >> day;cout <<"enter month: ";cin >> month;cout <<"enter year: ";cin >> year; Date today; today.setDate(day,month,year);today.getDate(); Date yesterday;yesterday.setDate(day-1,month,year);cout<<"Yesterday ";yesterday.getDate(); return 0;}arrow_forward
- public static void main(String [] args) { // Step 2: Construct a Day object representing today // and assign it to a variable called aDay // Step 3: Construct a Day object representing the day for our Exam1 on March 1, 2022, and assign it to a variable called examOne // // // Step 4: Declare three integer variables called year, month and day with initial values of 2022, 4, 12. // // 4 // Step 5: Construct a Day object using the three variables and assign it to a variable called examTwo 6. :7 28 29 // // Step 6: Display the three days on separate lines without any messages 30 31 // 32 33 // Step 7: Display the number of days as a positive integer between the two exams with a message 34 35 // 36 // "Number of days between the two exams: " 37 38 39 // Step 8: Update aDay to the day two days later 40 41 // Step 9: Print the year, month and day of aDay, one value per line without any messages 42 43 // 44 45 } 46 47arrow_forwardNeeds to be in JAVAarrow_forwardpublic class LabProgram { public static void main(String args[]) { Course course = new Course(); String first; // first name String last; // last name double gpa; // grade point average first = "Henry"; last = "Cabot"; gpa = 3.5; course.addStudent(new Student(first, last, gpa)); // Add 1st student first = "Brenda"; last = "Stern"; gpa = 2.0; course.addStudent(new Student(first, last, gpa)); // Add 2nd student first = "Jane"; last = "Flynn"; gpa = 3.9; course.addStudent(new Student(first, last, gpa)); // Add 3rd student first = "Lynda"; last = "Robison"; gpa = 3.2; course.addStudent(new Student(first, last, gpa)); // Add 4th student course.printRoster(); } } // Class representing a student public class Student { private String first; // first name private String last; // last name private double gpa; // grade point average…arrow_forward
- class Test { char paper[20]; int marks; public: Test () // Function 1 { strcpy (paper, "Computer"); marks = 0; } Test (char p[]) // Function 2 { strcpy(paper, p); marks = 0; } Test (int m) // Function 3 { strcpy(paper,"Computer"); marks = m; } Test (char p[], int m) // Function 4 { strcpy (paper, p); marks = m; } }; i. Write statements in C++ that would execute Function 1, Function 2, Function 3 and Function 4 of class Test. ii. Which feature of Object Oriented Programming is demonstrated using Function 1, Function 2, Function 3 and Function 4 together in the above class Test?arrow_forwardComputer Sciencearrow_forwardComputer Science c++ help comment code please. Complex has multiple parameters to overload i think. class Complex{public: Complex(); //There are no parameters because... Complex(double); //There is one parameter because... Complex(double, double);//There are two parameters because... double get_Real(); void set_Real(double); double get_Imaginary(); void set_Imaginary(double); friend ostream& operator << (ostream& out, Complex& r); //explain friend istream& operator >> (istream& in, Complex& r);//explainprivate: double real; double imaginary;}; ostream& operator << (ostream& out, Complex& r) //{ double a = r.get_Real(); double b = r.get_Imaginary(); if (a != 0)out << a; if (b < 0) out << "-" << abs(b) << "i"; if (b > 0 && b != 1) out << "+" << b << "i"; if (b == 0) out << "0"; if (b == 1 && a != 0) out << "+" <<…arrow_forward
- Case Diagram and UML Class Diagram for this java code : (Below the code give some constructive critiques about the UML class diagram)…. Thanks import java.util.*; public class BeverlyBreads{public static void main(String[] args){Scanner input = new Scanner(System.in); //Array for breads String[] breads = new String[5]; //Bread choices breads[0] = "White Bread"; breads[1] = "Wheat Bread"; breads[2] = "Rye Bread"; breads[3] = "Pumpernickel Bread"; breads[4] = "Baguette"; //Prices for the breads double[] prices = new double[5]; prices[0] = 2.99; prices[1] = 3.49; prices[2] = 3.99; prices[3] = 4.49; prices[4] = 4.99; //Customer's Name System.out.println("Enter customer's name: "); String name = input.nextLine(); //Customer's Phone Number System.out.println("Enter customer's phone number: "); String phoneNumber = input.nextLine(); //Bread Selection System.out.println("Which bread would you like to order?"); for(int i = 0; i < breads.length; i++) { System.out.println(breads[i] + "…arrow_forwarduse javaarrow_forwardCENGAGE MINDTAP Programming Exercise 3-10 |Instructions JobPricing.java 1 import java.util.Scanner; 2 class JobPricing { Herbert's Home Repair estimates each job cost as the cost of 3 public static void main(String[] args) { materials plus $35 per hour while on the job, plus $12 per hour for 4 String description; travel time to the job site. double materials; double hoursOn Job; double hoursTraveling; 7 The main() method prompts the user for the name of a job (for double price; Scanner input = new Scanner(System.in); System.out.print("Enter job description >> "); description = input.nextLine(); System.out.print("Enter cost of materials >> "); materials = input.nextDouble(); System.out.print("Enter hours on the job work » "); hoursOnJob = input.nextDouble(); System.out.print("Enter hours traveling >> "); hoursTraveling = input.nextDouble(); price = computePrice(materials, hoursOnJob, hoursTraveling); System.out.println("The price for " + description + 8 example, Smith bathroom…arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT