C++ coding | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

C++ coding

Enter the digit to show is factorial (for eg enter 5) Result 1 2 3 4 5 should be shown how to do in c++

11th Sep 2018, 6:45 AM
harjot
10 Answers
+ 4
Please show us your attempts at the problem first.
11th Sep 2018, 6:58 AM
Harsh
Harsh - avatar
+ 3
int a; cin >>a; int tot=1; int b =1; while (a != 0){ cout<< b << " "; tot = tot * a; a--; } cout <<tot;
11th Sep 2018, 7:11 AM
estifanos
estifanos - avatar
0
int i,n; c=0; cout<<“enter the digit”; cin>>n; for(i=0;i<=n;i++) c-; cout<<n<<endl;
11th Sep 2018, 7:03 AM
harjot
0
correct to get desired result
11th Sep 2018, 7:03 AM
harjot
0
#include <iostream> using namespace std; int main() { int user_input; cout << "enter a number\n"; cin >> user_input; for(int i = 1; i <= user_input; i++){ cout << i ; } return 0; }
11th Sep 2018, 7:04 AM
Ramphy Aquino Nova
Ramphy Aquino Nova - avatar
0
yes thnks
11th Sep 2018, 7:05 AM
harjot
0
if i want factorial like eg if put 5 then its factorial result should be shown 120
11th Sep 2018, 7:06 AM
harjot
0
can anyone tell im taking course of c++ where do i can practice more example to clear my understanding more to c++ coding any tips suggestion
11th Sep 2018, 7:18 AM
harjot
0
#include <iostream> using namespace std; int main() { int n; cin>>n; for(int i=1; i<=n; i++) { cout<<i<<" "; } return 0; }
30th Nov 2018, 4:51 PM
Parastoo Bahmani