For example printfthe factorial of 6 is dn factorial6

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ++; } } 4 Returned Values as Actual Arguments • Func4ons that return values may be used as actual arguments to other func4ons. for example: printf(“The factorial of 6 is %d.\n”, factorial(6)); /* assuming we have written function factorial */ /* which we’re about to… */ 5 Design Problem Write a program to calculate the factorial of numbers 1 to 10 and print the result to the screen. Write a user defined func4on for the factorial calcula4on using the provided prototype. Trace by hand the execu4on of the first 3 invoca4ons of func4on factorial. int factorial(int x); Factorial: The number of ways n objects can be linearly arranged. For an integer >= 0, n factorial (denoted n!) is defined by 0! = 1, n! = (n)(n ­1)(n ­2) … (3)(2)(1), for n>= 1. 6 Introduc4on to Arrays • ORen we...
View Full Document

Ask a homework question - tutors are online