Find Turbo C Factorial
1 Turbo C Factorial Loading
2 Turbo C Factorial Loading
3 Turbo C Factorial Loading
4 Turbo C Factorial Loading
5 Turbo C Factorial Loading
6 Turbo C Factorial Loading
Top Questions and Answers
plz help Write a program to calculate (20 number) ! ( factorial) with c? hi im learning C ( with turbo C++ 4.5 ) our teacher ask us if any one can bring a simple source code of factorial of 20 digit number i mean ( its over a belion number i think ) he asked us only C code not php or VB or anything else so if any one can write such a program please help me with it and i dont need any guide i need the program :D of course i need the headers to becuse i`m new to c and i want to learn the code ( headers like and ...> i also found a code in the internet but its a calculator and it has geraphic on it if any one want to watch it go to i didnt understand it ok guys im realy depending on u please help me with this for those 2 who just answer thx guys but like i said i only need a code which will work as i compiled ur code the compiler gaved me an error so if u plz test it first then tell me that would be great and by the way our teacher asked us to bring him a code to calculate only (20 number)! factorial he didnt say anything else so if u can write such program plz do so ... im waiting and thx @ Ajam thx but what is the header and what is this ??? i copy pasted ur code but it didnt work if u have msn messenger plz add me now so i can chat with u or any one who know what should i do my msn messenger id is : im using old version of msn messenger so if anyone want to send a message from yahoo or other messegner i dont know i can get it or not

~*Ajam*~ replied: "Sorry about that. I fixed the problem: #include // Need the climits file in order to know the maximum size of an unsigned // long int. #include // Declare the class. class Factorial { public: Factorial(unsigned short num = 1); bool inRange(); unsigned long getFactorial(); private: unsigned short num; }; // End of class. // Implement the methods: Factorial::Factorial (unsigned short num) { this->num = num; } bool Factorial::inRange() { // Maximum possible value for validation. unsigned long max = ULONG_MAX; // Loop from 1 to num, dividing the number from max. for (int i = num; i >= 1; --i) { max /= i; } // End of the for loop. // Return a true/false value. if (max < 1) { return false; } else { return true; } } // End of the factorialInRange() function. unsigned long Factorial::getFactorial() { // For the factorial. unsigned long sum = 1; // Loop from 1 to num, adding the result to the sum. for (int i = 1; i <= num; ++i) { // Multiply current sum times i. sum *= i; } // End of the for loop. return sum; } // end of the returnFactorial() function. // Start the main() function. int main() { // Declare the variable for the user input. unsigned short numberIn = 0; // Prompt the user, take, and validate the input. std::cout << "Enter a small, positive integer: [##] "; while (!(std::cin >> numberIn) || ((numberIn < 1) || (numberIn > 20))) { // Problem! Clear cin and reprompt. std::cin.clear(); std::cin.ignore(100, '\n'); std::cout << "I said, 'Please enter a positive integer.' Please: [##] "; } // End of WHILE. // Discard any extraneous input. std::cin.ignore(100, '\n'); // Create the object. Factorial f(numberIn); // Print the results. if (f.inRange()) { std::cout << "The factorial of " << numberIn << " is " << f.getFactorial() << ".\n\n"; } else { std::cout << "The factorial of " << numberIn << " cannot be calculated.\n" << "Use a smaller number.\n\n"; } std::cout << "Press enter. \n"; std::cin.get(); return 0; } // End of the main() function."

Jhered replied: "hmm a 20 digit number would be X * x-1 * x-2... x-19 I guess the big question is, does it ONLY do 20 digit numbers? heheh. been a while since i did c, i'm a c# dev... but here goes. Not even sure if a 'long' would hold your result or not... this won't work if a 'long' won't hold the result, it may overflow. void main() { long value; long result; cout << "Enter your number"; value << cin;//can't remember if you can do this in c or not... result = value; if(value > 1) { while(value > 1) { value = value - 1;//decrement value result = result * value;//multiply result by value } cout << result; } else { cout << "Must be a positive whole number greater than 1"; } } You know, thinking more about it, i don't think a long will hold the results... the Best way to do it would be a bit array and use binary multiplication. (can't say i remember how to do binary multiplication but it was something we covered in school...) basically make a bit array that holds enough bits to calculate 99999999999999999999! and do binary math the same as the above code. :) good luck"

What is Turbo C program for this problems? 1.) a program that would generate each of the following series of numbers on the screen this must be the output a 1 4 9 16 25 36 49 64 81 100 b 1 2 4 7 11 16 22 29 37 46 c 1 2 4 8 16 32 64 128 256 512 2.)The Series Numbers: 1, 1, 2, 3, 5, 8, 13, 21, ... is known as fibonacci series. each number is the sum of the two preceding numbers. write a program that reads in an arbitary number between 1 and 30 then display the fibonacci series of the number. 3.)the factorial of a non-negative integer n is written as n! (pronounced as "n factorial") and is defined as follows: n!=n*(n-1)*(n-2)*...*(for values of n greater than or equal to 1) and n!=1 (for n=0) write a program that reads a non-negative integer and computes and prints the factorial. 4.) write a program that estimates the value of the mathematical constant e by using the formula: e=1 +1/1 + 1/2! + 1/3! + ..... 1/n!

katnev replied: "Homework? work out yourself. I hope you are not lazy since you took the pains to type out such a long question, spend some more time to type out the programs that do this work."

Don M replied: "Answer 1(a) int x; int y; y = 0; for (x=0; y=100) { if (x%2==0) { y=y+x; } x++; } printf ("%d"; y);"

its_tru_its_damm_tru replied: "1a. is square of natural numbers 1.b. is given by formula a=1,b=1 print a a=a+b b++ repeat from second line 1.c. is given by formula a=1; print a a=a*2 repeat 2. fibonocci in this a=1,b=1 is set now print a set a=b b=a+b repeat from second line 3 and 4 u have formula now implement them"

Can anyone please help me in making a program in TURBO C!! URgenT!!? can u please send me the format on how to do this questions in turbo C. i really need it for the finals.!! Programming Problems: 1. Create a program that will determine the factorial of the inputted number. 2. Write a program that will read 10 numbers and will print the average, maximum and minimum values. 3. Write a program to read in numbers until the number -999 is encountered. The sum of all numbers read should be printed out. [please send me the format so that i can pass it tomorrow morning.! all I'm gonna do is copy it. please i really need help on this.! Note: this is done only in turbo C.]

William V replied: "So, you expect someone else to do your homework. That's pretty sad. If you expect to pass this course you had better learn how to do these (very) basic tasks."

Turbo c++ 3.0 help? Can someone help me to make a program that compute the factorial. #include plx.. XD

pıʌɐſ replied: "#include using namespace std; int main() { int number=0; int fact = 1; cout << "Enter your number; "; cin >> number; for (int i=1 ; i <= number ; i++) { fact *= i;} cout << "The factorial is: " << fact; return 0; }"

khazanchi replied: "#include void factorial() { int number,factorial,temp=1; printf("Enter the Number:"); scanf("%d", &number); while(number>0) { temp=temp*number; --number; } factorial=temp; printf("\nThe factorial of number is:%d",factorial); } int main() { factorial(); return 0; }"

help. turbo c program!! ASAP!? i have this program with me that will (supposedly) convert a rational number to a factorial. here is the code: #include int quo,prod; float point; int multiply(int quotient){ int i=0,k=0; k=fact2(quotient); do{ prod=k*i; i++; }while(prod<=quotient); prod=prod-(k); i=i-2; return(i); } int fact2(int quotient) { int f = 1,i=0; do { i++; f=f*i; }while(f<=quotient); f=f/(i--); return(f); } int factorial(int quotient) { int f = 1,i=0; do { i++; f=f*i; }while(f<=quotient); i--; return(i); } main() { int a,b,f; double ans,anss; clrscr(); printf("Input rational: "); scanf("%d/%d",&a,&b); ans=(float)a/b; printf("%d/%d = %f\n",a,b,ans); if(ans>0) printf("\n[0,["); else{ printf("\n[1,["); anss=ans*-2; ans=ans+anss; } quo=ans; point=ans-(quo+0.0); loop(quo); getch(); loop2(point); getche(); } int loop() { int fact,mul; while(fact>=1){ fact=factorial(quo); mul=multiply(quo); printf("%d,",mul); quo=quo-prod; } printf("],["); } loop2(float point) { float facto,mul2; while(point!=0){ facto=factorial2(point); mul2=multiply2(point); printf("%d,",mul2); point=point-prod; } } int multiply2(float point){ int i=0,k=0; k=facto2(point); do{ prod=k*i; i++; }while(prod<=point); prod=prod-(k); i=i-2; return(i); } int facto2(float point) { int f = 1,i=0; do { i++; f=f*i; }while(f<=point); f=f/(i--); return(f); } int factorial2(float poinnt) { int f = 1,i=0; do { i++; f=f*i; }while(f<=point); i--; return(i); } the problem is that it passes a different value of point. why does this happen? i need help badly. i hope you could help me. thanks in advance.

gene_frequency replied: "int factorial2(float poinnt) { int f = 1,i=0; do { i++; f=f*i; }while(f<=point); i--; return(i); } Right here, in factorial2(), the paramenter is "poinnt" -- which is never used in/by the function. The "point" used by the function is the global declared near the top of your code: int quo,prod; float point; ...bet that's why you're not getting expected results. TIP1: if you turn up the warning level your compiler, then it should warn you about unused parameters like "poinnt", and it'll help you find these problems more rapidly/easily. TIP2: this is why i always avoid use of globals whenever possible."

Turbo C problem (10 points)? Write a recursive function that will compute for the factorial of n. 10 points for you.....^_^ Why should I delete 10 points from my question?

Graham B replied: "Hi Try this: float fact(int n) { int f; for ( f = n - 1 ; f > 1 ; f-- ) { n *= f; } return n; } Hope it helps G"

ritz replied: "remove 10 pts from ur ques"

andreea_oschanitzky replied: "#include float f; /* global */ int n; /*=========================================================================*/ void Factorial(void) { int i; f = 1.0; for (i=2; i<=n; i++) f *= i; } /*=========================================================================*/ void main() { printf("n = "); scanf("%i",&n); Factorial(); printf("factorial = %g\n",f); } I don't remember the synthax as i should but it's the right ideea"

joby j replied: "Recursive fn: int fact(int n) { if(n==1) return 1; else return n*fact(n-1) } JJ"

turbo c code for program? can you please give me the code for a program that will compute the factorial value of n(as an input) and displays it. (use while loop, do while loop, and for loop) the output should be like this: enter a number: 5 the factorial value is: 120 optional: can you please give me the code for a program that will do the fibonacci series (you can use any type of loop) my code is not yet finished but it goes like this: #incude main() { int n; printf("Input number"); input=getche(); printf("for loop example"); for(n=input;n>=n*n;n++) that's all that i have finished but there are still errors and i need to use the 3 kinds of loop

tbshmkr replied: "Show your code. = We will help."

el e-phant replied: "uint fac = 0; cin>>fac; uint prod = 1; uint i = fac; while (i--){ prod = i * prod; } cout<
Turbo C program.. question? The factorial of N, where N is an integer, is define to be 1 if N is 0, and 1*2*3*4*5*.....*N if N is positive MAKE A PROGRAM THAT WOULD INPUT N, ENSURE THAT IT IS NON-NEGATIVE,AND OUTPUT SEQUENCE/SERIES AND ITS EQUIVALENT FACTORIAL. (PLEASE LEAVE AN EXPLANATION TO THE ANSWER TY.) The output will be look like this.. enter a num. 7 1*2*3*4*5*6*7 The factorial is 5040 But if you enter 0 or 8+.. it will give an eror message because 0 and 8+ is out of range.. like this enter 0 This is OUT of RANGE.. enter 8 This is OUT of RANGE..

Anand N replied: "include #include int main(){ int N; int fact = 1; int i = 0; printf("Enter N"); scanf("%d",&N); if(N>=0){ for(i=1;i<=N;i++) fact = fact* i; printf("Factorial is %d",fact); } else printf(" N cannot be Negative "); getch(); return ; }"

tbshmkr replied: "Show us your code. = We will try to help."

help me in TURBO C? here is my program? but there are errors, #include #include #define p printf #define s scanf void factorial(int ham) { int num; clrscr(); p("NON RECURSIVE\n\n"); p("Enter number: "); s("%d",num); p("the factorial value is: %d"); s("%d",ham); getch(); { int t,n; int ans=1; for(t=1;t<=n;t++) ans=ans*(t); } } i cant use iostream..

koppe74 replied: "You must use the address-of operator (&) in your scanf-arguments. You can only omit it when the arguments are already pointers -- actual pointers (e.g. int *) or arrays (e.g. char string[50]) -- which are addresses by default (the variable-name, return it's address). Otherwise (like for int) you must obtain the address with the &-operator. E.g.: s("%d",&num); Why do you use ham as an argument to the function, when the user must input it through scanf (line before getch)? (You'll also need the &-operator here)."

Marc replied: "So you are making a program to compute for the factorial of a number right? Here's my program which is much simpler. #include #include void main() { int num; clrscr(); cout<<"\nEnter the number: ";cin>>num; int t=1; for(int i=num;i>0;i--) { t = t * i; } cout<<"\n The factorial is: "<
More Websites
Find More
Turbo C Factorial © 2009