0

Write a programme in C++ that computes and displays a factorial of a number.

In c++

14th Apr 2017, 9:27 AM
Dominic Mutiso
Dominic Mutiso - avatar
5 Respuestas
+ 4
why?
14th Apr 2017, 9:33 AM
Mario L.
Mario L. - avatar
14th Apr 2017, 9:36 AM
देवेंद्र महाजन (Devender)
देवेंद्र महाजन (Devender) - avatar
+ 2
#include<iostream.h> #include<conio.h> void main() { int x; //The required number to be entered by the user. int product=1; //The required result. cout<<"Welcome user, enter the number of your desire to find its factorial="; cin>>x; if(x>0) for(int i=x;i>0;i--) { product*=i; } else product=1; cout<<"The requested number="<<x; cout<<x; for(i=x-1;i>0;i--) { cout<<"X"<<i; } cout<<"\nThe desired factorial="<<product; cout<<"\n\n\t\tTHANK YOU FOR USING MY PROGRAM(VARUN SINGH)"; getch(); } here you go bro.
14th Apr 2017, 11:10 AM
DEVIL kingg
DEVIL kingg - avatar
+ 1
@Abhishek Shrivastava :Yes, you are correct bro,its just that i forgot to copy my corrected code and posted this one.. About using outdated compilers/c style coding. I'am much more comfortable in it also that i just started learning c++ so i dont know much and my teacher even didnt responded to most of my queries so here iam with such a style of coding.
15th Apr 2017, 8:13 AM
DEVIL kingg
DEVIL kingg - avatar
0
@Varun Singh : Should there be <<x only after "The requested number=" because you have used cout<<x just after it and also a for loop is there to represent the factorial in expanded from. I think that should be cout<<"The requested number=" <<x<<"!\n=" And one more thing.... Why you still prefer C style of coding using outdated compilers or IDEs ?
14th Apr 2017, 11:29 AM
Abhishek Kumar
Abhishek Kumar - avatar