0% found this document useful (0 votes)
43 views

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
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views

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
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