Factorial codes in C++ program
Hi Archie using C++ it is very easy to perform operation of factorial and also remember that values can be given both statistically and dynamically at runtime.
The syntax is different from one language to another language but the logic will be same in any language so first try to note the logic and then we can implement in our program by syntax easily.
As you know that execution starts from main() you have to insert the logic of the function in the main method only otherwise you will not get the correct output.
Logic is nothing but as follows…
for(f=1;f<=4;f++)
factorial=factorial*f;
here factorial and f are the variables where as factorial variable gets the output by using printf command.
Hence then you can get the exact output of the value which you give by implementing logic in the main method and compile and run it without errors.
Thank You.
Factorial codes in C++ program
Hi there ,Â
It seems you need the code for finding a factorial.
I hope only the mathematical logical parts are confusion for you and i hope you are thorough with the C++ basics.
I am giving you the codes of the formulated algorithm , These can be done with other looping statements like for loop and all , I suggest this way.
Here are the codes :-
//Write the codes to get the limit of the factorial to be produced into the "lim" varaible.
//thenÂ
long int i=0,fact=1;
i=lim;
while(lim!=0)Â
{
fact = fact * lim;
— lim;
}
// Now type the code to print the variable "fact" , and that is your factorial of the given limit.
I hope you are clear and your problem is solved
good luck.
Factorial codes in C++ program
Yes very clear and got all your steps. Thanks  a lot for the help Lesten. Keep it up! Hope you continouosly help others just what you did now.. thanks