In your program for HW4- Telephone Service Simulation,  when is_valid_areacode() is being executed, which functions will have their activation frames in the stack?  Support your answer by attaching a screenshot from the visual studio code

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

This is the code only for reference:

#include<bits/stdc++.h>

using namespace std;

 

int main()

{

//user input

cout<<"Enter the 10 digit phone number: ";

string phone_num;

cin >> phone_num;

 

//by using array<T make valid area code

string arr[] = {"405", "520", "550", "650", "620"};

// If the phone number is not of 10 digit

if (phone_num.length()!=10)  //by using if else loop

cout << "Invalid phone number";

else{

 

int choice;

// Ask user for the choice of execution of program

cout << "Enter 1 for if else statement and 0 for switch case statements. ";

cin >> choice;

 

string area_code = phone_num.substr(0,3);

int area_cd = stoi(area_code);

if (choice == 1){

// use substr function to extract the first three digit

// Use of the find function to check if the code is valid

if (find(begin(arr),end(arr),area_code)!=end(arr)){

cout << "The area code is "<<area_code;

}

else{

cout << "Invalid area code";     //if  user enter some other  number

}

}

else{

// Convert into integer and use of switch cases

switch(area_cd){

case 405:

cout << "The area code is 405";

break;

case 520:

cout << "The area code is 520";

break;

case 550:

cout << "The area code is 550";

break;

case 650:

cout << "The area code is 650";

break;

case 620:

cout << "The area code is 620";

break;

default:

cout << "Invalid area code";

}

}

}

return 0;

}

ANSWER FOR THIS QUESTION ONLY 

1. a) In your program for HW4- Telephone Service Simulation,  when is_valid_areacode() is being executed, which functions will have their activation frames in the stack?  Support your answer by attaching a screenshot from the visual studio code

 

 

Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education