Answer to Question #279633 in C++ for Andrea

Question #279633

Write a C++ program to display Pascal's triangle.


Test data:


Input the number of rows : 5


Expected output:



1


1 1


1 2 1


1 3 3 1


1 4 6 4 1




Write a program in C++ to find the number ang sum in all integer between 100 and 200 which are divisible by 9.


Expected output:


Number between 100 and 200, divisible by 9.


108 117 126 135 144 153 162 171 180 189 198



1
Expert's answer
2021-12-14T13:33:50-0500
#include<iostream>
using namespace std;
int main(){
	int r,col=1,b,x,n;
    cout << "\n\n Outputing Pascal's triangle:\n";
  
    cout << " Enter number of rows: ";
    cin >> r;
    for(x=0;x<r;x++)
    {
        for(b=1;b<=r-x;b++)
        cout<<"  ";
        for(n=0;n<=x;n++)
        {
            if (n==0||x==0)
                col=1;
            else
               col=col*(x-n+1)/n;
            cout<<col<<"   ";
        }
        cout<<endl;
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog