0

Write a Pascal triangle program

18th Jun 2016, 7:22 PM
Ogunjirin Emmanuel
Ogunjirin Emmanuel - avatar
3 Respuestas
+ 1
Hi Emmanuel, this is not a question. Also, would you be so kind to tell me why you want an answer to a commonly used exercise that is used for teaching programming while your achievements miss the achievement for completing a single lesson in Solo Learn C++?
19th Jun 2016, 12:41 AM
Stefan
Stefan - avatar
+ 1
#include<iostream> using namespace std; int main() { int rows; cout << "Enter the number of rows : "; cin >> rows; cout << endl; for (int i = 0; i < rows; i++) { int val = 1; for (int j = 1; j < (rows - i); j++) { cout << " "; } for (int k = 0; k <= i; k++) { cout << " " << val; val = val * (i - k) / (k + 1); } cout << endl << endl; } cout << endl; return 0; }
19th Jun 2016, 2:07 AM
Navishta Hashmi
Navishta Hashmi - avatar
0
This is a program for Pascal's triangle. Hope this helps you.
19th Jun 2016, 2:07 AM
Navishta Hashmi
Navishta Hashmi - avatar