Software Development Exam  >  Software Development Notes  >  Basics of C++  >  Code: Pascal's Triangle

Code: Pascal's Triangle | Basics of C++ - Software Development PDF Download

Code: Pascal`s Triangle | Basics of C++ - Software Development

C++ Program for Pascals Triangle Pattern

#include<iostream>


using namespace std;


void PascalsTriangle(int n) {


  for (int i = 1; i <= n; i++) {

    int coef = 1;

    for (int k = n - i; k > 0; k--) {

      cout << " ";

    }

    for (int j = 1; j <= i; j++) {

      cout << coef << " ";

      coef = coef * (i - j) / j;


    }

    cout << endl;

  }

}


int main() {

  int num;

  cout << "Enter number of levels of the pattern :" << endl;

  cin >> num;

  PascalsTriangle(num);


  return 0;

}

The document Code: Pascal's Triangle | Basics of C++ - Software Development is a part of the Software Development Course Basics of C++.
All you need of Software Development at this link: Software Development
70 videos|45 docs|15 tests

Top Courses for Software Development

70 videos|45 docs|15 tests
Download as PDF
Explore Courses for Software Development exam

Top Courses for Software Development

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

Exam

,

Sample Paper

,

Important questions

,

ppt

,

Semester Notes

,

video lectures

,

Previous Year Questions with Solutions

,

Viva Questions

,

Objective type Questions

,

past year papers

,

Summary

,

Extra Questions

,

Free

,

pdf

,

shortcuts and tricks

,

mock tests for examination

,

MCQs

,

Code: Pascal's Triangle | Basics of C++ - Software Development

,

study material

,

Code: Pascal's Triangle | Basics of C++ - Software Development

,

Code: Pascal's Triangle | Basics of C++ - Software Development

,

practice quizzes

;