How to make Pascal triangle in C++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to make Pascal triangle in C++

I am trying to make Pascal triangle https://code.sololearn.com/csLzNm1FqqTp/?ref=app

30th Aug 2017, 12:21 PM
Sushmit Mishra
Sushmit Mishra - avatar
3 Answers
+ 13
Here is a good instruction for you, Sushmit. https://www.programiz.com/cpp-programming/examples/pyramid-pattern
30th Aug 2017, 1:18 PM
Babak
Babak - avatar
+ 13
#include <iostream> using namespace std; int main() { int n; cin>>n; for (int i = 0; i < n; i++) { for (int j = 1; j < (n - i); j++) { cout << " "; } for (int k = 0; k <= i; k++) { cout << " " <<"^"; } cout << endl << endl; } cout << endl; return 0; }
30th Aug 2017, 1:23 PM
P R
P R - avatar
+ 4
use this algorithm :- int n; cin>>n; for(int i=1;i<=n;i++) { for(int j=i;j<=n;j++) cout<<" "; for(int k=1;k<=i;k++) cout<<k; for(int l=i-1;l>=1;l--) cout<<l; cout<<endl; }
30th Aug 2017, 1:58 PM
RZK 022
RZK 022 - avatar