Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Section B (36%) - Short Questions Answer ALL questions in this section in the answer book provided. Each question carries 12 marks. Question B1 Write
Section B (36%) - Short Questions Answer ALL questions in this section in the answer book provided. Each question carries 12 marks. Question B1 Write your code for the main() function to produce the required sample outputs. The program asks the user for an 8-digit phone number. If the entered number is not an 8-digit number, it prints an error message and asks the user to input again until it is correct. It then prints whether it is a "fixed-line" number (a number that starts with 3 or 5), a "mobile" number (a number that starts with 6 or 9), or an "invalid" number (other cases). #include using namespace std; int ( operatorname{main}() ) i int phone_num; cout ( ll ) "Enter 8-digit phone number: "; cin ( gg ) phone_num; // Your codes for B1 should be inserted here return 0 ; } Sample output 1: Enter 8-digit phone number: 35124859 Fixed-line Sample output 2: Enter 8-digit phone number: 60125547 Mobile Sample output 3: Enter 8-digit phone number: 41242252 Invalid Sample output 4: Enter 8-digit phone number: 545678 Incorrect format. Re-enter: 545678912 Incorrect format. Re-enter: 54567891 Fixed-line (12 marks) Page 6 of 14
in c++
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started