Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C++ program (cpp) which repeatedly asks the user to enter their contact

ID: 3773643 • Letter: W

Question

Write a C++ program (cpp) which repeatedly asks the user to enter their contact numbers. Create a string variable named “Phone_No” and take the input in the following pattern: “+92423672123” where the first three characters represent country code (e.g., +92 as shown in the example pattern), next two characters (e.g., 42 according the shown example number) represent the city code, while next 7 characters represent the actual number.   Your task is to display appropriate messages for the numbers belonging to three cities: Islamabad (having city code 51), Lahore (city code 42), and Karachi (city code: 21). Any number having different country code or city code must be reported as “Un-known number“. Please also ensure that the user must enter the number according to the shown pattern only and the size of the input string must be 12 characters.

ie
#include <iostream>
#include <string>
using namespace std;
void main ()
{
?????
?????Solve here!!!
}

Explanation / Answer

#include <iostream.h>

#include<string.h>

#include<stdio.h>

void main()

{

int countrycode,citycode,num,phonenum;

cout<<Enter City Code Eg.,(for the numbers belonging to three cities: Islamabad (having city code 51), Lahore (city code 42), and Karachi (city code: 21)).

cin>>citycode;

cout<<Enter Actual number.Like 7 digits number;

cin>>num;

cout<<Enter ur country code;

cin>>countrycode;

if((ccode==51||ccode==42||ccode==21) && (strlen(num)==7))

{

cout<<"Phone_No is:+"+countrycode,+citycode,+num;

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote