Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q.2. Write C++ code for the following: a) Here's a function: int times2inta) { return (a*2); } Write a main () program that includes everything

image text in transcribed

Q.2. Write C++ code for the following: a) Here's a function: int times2inta) { return (a*2); } Write a main () program that includes everything necessary to call this function. b) Raising a number n to a power p is the same as multiplying n by itself p times. Write a function called power() that takes a double value for n and an int value for p, and returns and display the result as a double value. Write a main () function that gets values from the user to test this function. c) A phone number, such as 051 1212123, can be thought of as having two parts: the area code (051) and the number (1212123). Write a program that uses a structure to store these two parts of a phone number separately. Call the structure 'phone'. Create two structure variables of type 'phone'. Initialize one (suppose it has been initialized as 051 1111111. This is just for example, you can change it), and have the user input a number for the other one. Then display both numbers. HINT: The interface/communication might look like this: Enter your area code: 051 Enter your number: 042 45454545 The stored/initialized number is: 051 1111111 Your entered number is 042 45454545

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals Design And Implementation

Authors: KROENKE DAVID M.

1st Edition

8120322258, 978-8120322257

More Books

Students also viewed these Databases questions

Question

What are the three strategic themes of the financial perspective?

Answered: 1 week ago

Question

=+5. What is your impression of the Carbon Principles?

Answered: 1 week ago

Question

What is operatiing system?

Answered: 1 week ago