Sponsored Content
Full Discussion: Help!
Top Forums UNIX for Dummies Questions & Answers Help! Post 302095644 by tony1leg on Wednesday 8th of November 2006 06:21:49 PM
Old 11-08-2006
Bug Help!

Hi everyone!
I am new to the board and new to Unix. Getting used to it but still have alot of trouble with it.
I need to write a program that generates factorial of a number by input of the user. It should be an input between 1 and 10 and check to see if it is within a range. I should also write a function called "factorial" which has a prototype of void factorial(int num); and finally, I should call the function to from the main program. here is what i got so far. any input, tips, or anything at all would be greatly appreciated. i really need the help. i look forward and greatly appreciate any help and hope to learn alot more with you all at this site.

Code:
# include <stdio.h>
# include <math.h>

void factorial(int num);

int main(void)


{

int num;
int factorial;
int factor;

printf("Enter a positive integer between 0 and 10: ");
scanf("%d", &num);
if (num < 0){
   printf("This negative factorial %d will be undefined.\n", num);
}else if (num <=10){
   factor = factorial(num);
   printf("The factorial of %d is %d\n", num, factor);
}else {
   printf("Number is out of the range of.  Please try again\n");
}

return (0);

}

void
void
factorial(int num)
{
int num_a = num;
int factor_1 = 1; 
int factor;  
   
factor = factor_1 * num_a;
   
return(factor);

}

cheers

Last edited by reborg; 11-08-2006 at 09:23 PM..
 
HOOLA(6)							  Freecell Solver							  HOOLA(6)

NAME
freecell-solver-range-parallel-solve - The Freecell Solver utility for solving a range of Microsoft Freecell/Freecell Pro Boards SYNOPSIS
freecell-solver-range-parallel-solve start end print_step [--binary-output-to filename] [--total-iterations-limit limit] [fc-solve Arguments...] DESCRIPTION
freecell-solver-range-parallel-solve is a command line application that solves a range of Freecell deals of Microsoft Freecell and Freecell Pro. start is the first board to solve; end is the last (inclusive) and print_step is the division of board numbers in which to print a status message. Following this three mandatory parameters are several flags specific to the range solve. (refer to the OPTIONS section for more information) Afterwards one can give it a fc-solve command line that it will use to solve each board. Refer to the fc-solve(6) man page for information about its options. OPTIONS
--total-iterations-limit sets the maximal number of iterations with which to try to solve each deal. After that, the program will give up and report that the board was intractable. --binary-output-to sets the filename into which to output the number of iterations it took to solve each board. This file can later be used with statistical preset optimizers such as those found in the Freecell Solver version control repository. SEE ALSO
fc-solve(6) AUTHOR
Shlomi Fish, <http://www.shlomifish.org/> . Freecell Solver 3.12.0 2012-06-22 HOOLA(6)
All times are GMT -4. The time now is 02:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy