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
EBK CONCEPTS OF PROGRAMMING LANGUAGES
Additional Engineering Textbook Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Management Information Systems: Managing The Digital Firm (16th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Web Development and Design Foundations with HTML5 (8th Edition)
- 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_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_forwardclass 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_forward
- Computer 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_forwarduse javaarrow_forwardJAVA PROGRAM Introduction The goal of this project is to develop a nontrivial computer program in the Java language by applying elementary programming language concepts learned so far. Specifically, the concepts to be used for this project include simple input/output, selection, iteration (loops), and possibly one-dimensional arrays (although the use of arrays is not required for completing this project). Developing a Java program for printing a calendar Statement of Problem: Develop a Java program to print a calendar for the year that the user will provide as an input to the program. Use the Eclipse IDE (on a Windows or Mac machine). Your program must fulfill the following requirements: Your program should prompt and receive as input an integer value representing the year for which the user wishes to have a calendar printed. This integer must be in the range from 1780 through 2040. In case the user input a year that is outside this range, your program must print out a message such as…arrow_forward
- Please help me with this in c++. A simulation creates a model of a real-world situation, allowing us to introduce a variety of conditions and observe their effects. For instance, a flight simulator challenges a pilot to respond to varying conditions and measures how well the pilot responds. Simulation is frequently used to measure current business practices, such as the number of checkout lines in a grocery store or the number of tellers in a bank, so that management can determine the fewest number of employees required to meet customer needs. Airlines have been experimenting with different boarding procedures to shorten the entire boarding time, keep the flights on-time, reduce aisle congestion, and make the experience more pleasant for passengers and crew. A late-departing flight can cause a domino effect: the departure gate is tied up and cannot be used by other landing or departing flights, passengers on board the late flight may miss connecting flights and require rebooking and…arrow_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_forwardC programming Fill in the blanks.arrow_forward
- in c++ using 2D Arrays The following diagram represents an island with dry land (represented by “-“) surrounded by water ((represented by “#“). ##-########## #-----------# #-----------# #------------ # -----------# #------X----# #-----------# ############# Two bridges lead off the island. A mouse (represented by “X”) is placed on the indicated square. Write a program to make the mouse take a walk across the island. The mouse is allowed to travel one square at a time, either horizontally or vertically. A random number from 1 to 4 should be used to decide which direction the mouse is to take; for the sake of uniformity assume that 1 = up, 2 = down, 3 = left, and 4 = right. Since the mouse is wearing cement mouse galoshes, the mouse drowns when he hits the water. He escapes when he steps on a bridge. You may generate a random number up to 100 times allowing the mouse to take 100 steps. If the mouse does not find a bridge by the 100th try, he will wither away and die of starvation.…arrow_forwardInput class ternary_operator { public static void main(String args[]) { int x = 3; int y = ~ x; int z; z = x > y ? x : y; System.out.print(z); } } Find outputarrow_forwardExercise 1 - What is wrong in the code below: public class Main { public static void main(String[] args) { int x = 5 int y = 10; int z = x + y; System.out.println(z); }} Exercise 2 - What is wrong in the code below: public class Main { public static void main(String[] args) { int x = 5; int y = 0; int z = x / y; System.out.println(z); }} Exercise 3 - What is wrong in the code below: public class Main { public static void main(String[] args) { int x = 5; int y = 10; int z = x - y; System.out.println("The difference between " + x + " and " + y + " is " + z); }} Exercise 4 - What is wrong in the code below: public class Main { public static void main(String[] args) { int 1stNumber = 5; int second_number = 10; int sum = 1stNumber + second_number; System.out.println(sum); }} Exercise 5 - What is wrong in the code below: public class Main { public static…arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT