Search
 
SCRIPT & CODE EXAMPLE
 

CPP

Pascal triangle using c++

#include <iostream>
using namespace std;


int fact(int num){
    int factorial = 1;
    for (int i = 2; i <= num; i++)
    {
        factorial = factorial * i;
    }
    return factorial;
}

int main(){
    int n;
    cout << "Enter number of rows: ";
    cin >> n;

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j <=i; j++)
        {
            cout << fact(i) / (fact(j) * fact(i - j)) << " ";
        }
        cout << endl;
    }
    
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: how to remove a index from a string in cpp 
Cpp :: sqrt in c++ 
Cpp :: find duplicate from an array c++ 
Cpp :: swap elements array c++ 
Cpp :: stack implementation using class in c++ 
Cpp :: how to sort vector of struct in c++ 
Cpp :: long to string cpp 
Cpp :: untitled goose game 
Cpp :: C++ Vector Operation Add Element 
Cpp :: c++ basic snippet 
Cpp :: c++ progress bar 
Cpp :: memory leak in cpp 
Cpp :: c++ vs g++ 
Cpp :: C++ fill string with random uppercase letters 
Cpp :: c++ contains 
Cpp :: classes constructor in c++ 
Cpp :: opengl draw semi circle c++ 
Cpp :: convert kelvin to Fahrenheit 
Cpp :: how to cout in c++ 
Cpp :: Visual studio code include path not working c++ 
Cpp :: ++ how to write quotation mark in a string 
Cpp :: c++ get pointer from unique_ptr 
Cpp :: C++ Integer Input/Output 
Cpp :: sum array c++ 
Cpp :: abstraction in cpp 
Cpp :: put text on oled 
Cpp :: bfs sudocode 
Cpp :: Initialize Vector Iterator 
Cpp :: flutter single instance app 
Cpp :: how to pass an array by reference in c++ 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =