Question: 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. Fach 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 enterod 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 "imvalid" number (other cases). \#friclude Ciostream? using famespace atd? int main () Int phone tum: cout "Enter 8-digit phone number: " ? cin phone num? // Your codes for B1 should be inserted here return 0; 1 Sample output I: Enter 8-digit phone number: 35124859 Fixed-1ine Sample output 2: Fnter 8-digit phone number: 60125547 Mobile Sample output 3 : Enter 8-digit phone number: 41242252 Imvalid Sample output 4: Sampicoutput 4: Enter 8-difit phone number: 545678 Incorrect Cormat. Re-enter: 545678912 Incorrect format. Re-enter: $4567891 Fixed-ine (12 marks) Page 6 of 14
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
