cProgHWFacoTest

cProgHWFacoTest -...

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

View Full Document Right Arrow Icon
C PROGRAMMING HOMEWORK “FACO-TEST” #include<stdio.h> #include<stdlib.h> int factorial(int); int main() { int number, result; for(;;) { printf("Please Enter A number to get it's factorial: "); //getting our target number scanf("%d", &number); if(number=0) { break; } } //calling the function result = factorial(number + 1); //printing out results printf("\nThe factorial is : %d", result);
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: printf(&quot;\n\n\n\n\n\n&quot;); system(&quot;PAUSE&quot;); return 0; } int factorial(int victim) { if(victim&gt;1) { victim = victim - 1; /*this is the whole point where you actually call the same function which you are into, it is called a recursive function. */ victim = victim * factorial(victim); } return victim; }...
View Full Document

This note was uploaded on 03/30/2008 for the course CS 212 taught by Professor Dr.frey during the Spring '06 term at New Haven.

Ask a homework question - tutors are online