0% found this document useful (0 votes)
45 views1 page

Functions Exercise

A function called power() takes a double n and integer p as arguments, with p defaulting to 2, and returns a double by multiplying n by itself p times, squaring n if p is omitted. A main() function gets user input to test power().

Uploaded by

MAHESH V
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views1 page

Functions Exercise

A function called power() takes a double n and integer p as arguments, with p defaulting to 2, and returns a double by multiplying n by itself p times, squaring n if p is omitted. A main() function gets user input to test power().

Uploaded by

MAHESH V
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

1)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 the rseult as a double value. Use a default argument of 2 for p , so that
if this argument is omitted, the number n will be squared. write a main() function
that gets values from the user to test this funtion.

You might also like