62 568
Assignments Done
99%
Successfully Done
In June 2018

Answer to Question #4573 in C++ for Yuri

Question #4573
Create a program that will output below:
1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1
1 7 21 35 35 21 7 1
1 8 29 56 70 56 29 8 1
1 9 37 85 126 126 85 37 9 1
1 10 45 112 211 252 211 112 45 10 1


pls use only any of the following: array, loop structure or decision structure
thanks :)
Expert's answer
#include "StdAfx.h"
#include <iostream>

using namespace std;

double Cnk(int N,int K)
{
& double Sum = 1;
& for (int i = 1; i <= K; i++)
& Sum*=(N-i+1)/float(i);
& return Sum;
}

int main()
{

int n = 10;

& //cout<<"enter dimention ";
& //cin>>n;

for (int j = 0; j <= n; ++j, cout<<endl)
& for (int i = 0; i <= j ; ++i)
cout<<Cnk(i, j);

system("pause");
& return 0;
}

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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions