Question

C++: Write a program that computes and displays a full binomial expansion, such as (x+y)^n where...

C++: Write a program that computes and displays a full binomial expansion, such as (x+y)^n where only n is asked for by the user.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer-

C++ program.

#include <iostream>
#include <math.h>
using namespace std;
  
void expansion(int x, int y, int n) //function for calculating the expansion.
{
int value = pow(x, n); //calculating first term of expansion
cout << value << " ";
  
for (int i = 1; i <= n; i++) //calculating and printing remaining values of expansion
{

value = value * y * (n - i + 1)/(i * x);
cout << value << " ";
}
}
  
int main()
{
int x = 3, y = 4, n;
cout<<" Enter the value of n = "; //user input n
cin>>n;
expansion(x, y, n); //calling the function for expansion calculation
return 0;
}

Screenshot of Program-

Add a comment
Know the answer?
Add Answer to:
C++: Write a program that computes and displays a full binomial expansion, such as (x+y)^n where...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT