Pages

Subscribe:

About Template

Random Posts

C++ Program of The Integral Of Every Terms


Name: Integral Of Every Terms
Description of the Program: This program displays the integral of each term of expression.

In the screenshot below, I entered 5 terms that I would like to integrate and the five values of coefficients and exponents. Then, it displayed the whole term of expression that I have entered and the integral of the expression in fraction and in decimal.
//Below are the Codes of the Program:

#include <windows.h>
#include <iostream.h>
#include <math.h>
#include <string.h>
#include <cstring.h>
#include <conio.h>

double coeff1[100]={0};
double exponent1[100]={0};
int b;
void dual_swap(double&amp;a,double&amp;b,double&amp;x,double&amp;y)
{double c,d;
c=a;
a=b;
b=c;
d=x;
x=y;
y=d;
}

int main()
{
string num_coeff;
cout&lt;&lt;"How many terms would you like to integrate: ";    cin&gt;&gt;b;


for(int x=0;x<b;x++) cout="" {="">&lt;&lt; "\n\nEnter the value of coefficient "&lt;<x+1>&lt;&lt;": \t\t";      cin &gt;&gt; coeff1[x];
cout &lt;&lt; "\nEnter the value of exponent "&lt;<x+1>&lt;&lt;": \t\t";      cin &gt;&gt; exponent1[x];
}


for(int aa=0;aa<b;aa++) as="0;as&lt;b;as++)" for(int="" if(exponent1[as]="" {="">exponent1[as+1]&amp;&amp;as+1<b)>
dual_swap(exponent1[as],exponent1[as+1],coeff1[as],coeff1[as+1]);
}
}


cout &lt;&lt; "\n\n\nYou have entered: \n";
for(int x=0;x<b;x++)>
{cout&lt;&lt; coeff1 [x]&lt;&lt; "x^" &lt;&lt; exponent1[x];

if(x!=b-1)
cout&lt;&lt; " + ";
}

cout&lt;&lt; "\n\n\nYour new integral in fraction: \n";
for(int x=0;x<b;x++)>
{
cout&lt;&lt;"("&lt;&lt; coeff1[x] &lt;&lt; "/" &lt;&lt; exponent1[x] + 1&lt;&lt; ")x^" &lt;&lt; exponent1[x] + 1;
if(x!=b-1)
cout&lt;&lt; " + ";
}

cout&lt;&lt; "\n\n\nOr in decimal: \n";
for(int x=0;x<b;x++)>
{
cout&lt;&lt;"("&lt;&lt; (coeff1[x]) /(exponent1[x] + 1)&lt;&lt; ")x^" &lt;&lt; exponent1[x] + 1;
if(x!=b-1)
cout&lt;&lt; " + ";
}

getch();
return 0;
}