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
Are you preparing for Software Development Exam? Then you should check out the best video lectures, notes, free mock test series, crash course and much more provided by EduRev. You also get your detailed analysis and report cards along with 24x7 doubt solving for you to excel in Software Development exam. So join EduRev now and revolutionise the way you learn!
Sign up for Free Download App for Free
70 videos|45 docs|15 tests

Up next

70 videos|45 docs|15 tests
Download as PDF

Up next

Explore Courses for Software Development exam
Related Searches

study material

,

Extra Questions

,

Important questions

,

video lectures

,

Free

,

shortcuts and tricks

,

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

,

Objective type Questions

,

Sample Paper

,

past year papers

,

Viva Questions

,

Previous Year Questions with Solutions

,

ppt

,

MCQs

,

Summary

,

Semester Notes

,

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

,

practice quizzes

,

mock tests for examination

,

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

,

pdf

,

Exam

;