I have this code, but I need a flowchart that shows how my program works, and the inputs and outputs???
#include <iostream>
#include <cmath>
using namespace std;
int fact(int n)
{
int i;
int c = 1;
for(i=1; i<=n; i++)
{
if(n==0)
c = 1;
else
c = c*i;
}
return c;
}
double ex(int n,double x)
{
int i;
double c = 0.0;
for(i=0; i<=n; i++)
{
c = c + (double)(pow(x,i)/ (double)fact(i));
}
return c;
}
double sinx(int n,double x)
{
int i;
double c = 0.0;
double xInRadian = (3.14 / 180.0)* x;
for(i=0; i<=n; i++)
{
if(i%2==0)
c = c + (double)(pow(xInRadian,2*i+1)/double(fact(2*i+1)));
else
c = c - (double)(pow(xInRadian,2*i+1)/double(fact(2*i+1)));
}
return c;
}
double cosx(int n,double x)
{
int i;
double c = 0.0;
double xInRadian = (3.14 / 180.0)* x;
for(i=0; i<=n; i++)
{
if(i%2==0)
c = c + (double)(pow(xInRadian,2*i)/double(fact(2*i)));
else
c = c - (double)(pow(xInRadian,2*i)/double(fact(2*i)));
}
return c;
}
int main()
{
double x;
int n;
cout<<"Enter the value of x: ";
cin>>x;
cout<<"\nEnter the number of terms to be executed: ";
cin>>n;
cout<<"\ne to power of x = "<<ex(n,x);
cout<<"\nsin("<<x<<") = "<<
sinx(n,x);
cout<<"\ncos("<<x<<") = "<<
cosx(n,x);
return 0;
}
Main Function:

flowchart for Function Fact

Flowchart for Function exp

Flowchart for Sinx function

Flowchart for cosx function

Input: 12
Output:

I have this code, but I need a flowchart that shows how my program works, and...
NEED HELP IN C++, IT'S UGENT. I been trying to figure out for hours what is wrong with my code. I can not get the first derivative to display and its evaluation to display. my code is below: #include <iostream> #include <cmath> #include <iomanip> #include <string> #include <sstream> using namespace std; string polyToString(double poly[]) { stringstream ss; if (poly[0] == 0) { ss << poly[1]; } if (poly[0] == 1) { int a = poly[1]; int b = poly[2];...
How do can I update this code (Code A): Code (A) #include using namespace std; int fibonacci(int n) { int a = 0, b = 1, c; if (n <= 1) return n; for (int i = 2; i <= n; i++) { c = a + b; a = b; b = c; } return b; } int fibonacciRecursive(int n) { if (n <= 1) { return n; } return fibonacciRecursive(n-1) + fibonacciRecursive(n-2); } int main() { int n;...
Can someone help me fill in the first part of this c++ code: I need it to print the menu based on the day selected. #include #include using namespace std; int main(){ double sub_total=0,tax=0,total=0; string food1[3]={"T-Bone Steak","Pork Chops","Iceland Cod"}; double prices_f1[]={20.50,15.45,10.55}; string food2[3]={"Sirloin Steak","Salmon Fillet","Jumbo Shrimp"}; double prices_f2[]={30.35,24.50,15.50}; string food3[3]={"Pork Tenderloin","Buffalo Chicken Sandwhich","Avocado Burger"}; double prices_f3[]={10.60,15.60,25.60}; string drink1[3]={"Raspberry Sgroppino","Sparkling Apple Sangria ","Spiced Cranberry Rum"}; double prices_d1[]={2.55,5.75,4.25}; string drink2[3]={"Champagne Mojitos","Roman Hoilday Cocktail","Dry Martini"}; double prices_d2[]={1.5,3,25,8.45}; string drink3[3]={"Radler Beer","Port wine","Primm's"}; double prices_d3[]={3.55,2.25,4.45};...
*** I need help identifying my incoming parameters, outgoing parameters, and return values in the C++ code below. There are 4 functions in the code below and the 3 fields for each function are bolded. Should one of the items not exist, put N/A. **** #include #include using namespace std; int input(long long); // function to Input of Base 2 value to enforce the entry of only 1's and 0's int input2(double); int Base10toBase2(long long); // Base 10 to Base...
Cant find what is wrong to fix the code. can you please fix the code. The function is: sin^-1 (x/5) #include <iostream> #include <iomanip> #include <math.h> #include <cmath> using namespace std; double f(double x) { return pow(sin, -1)*(x / 5); } int main() { int i, n; double a = 0.0, b =1.0, h, s = 0.0, x, xbar; double s1, s2, s3; cout << " Enter # of partitions n "; cin >> n; cout << " n =...
my program wont run on my computer and im not understanding why. please help. #include<iostream> #include<iomanip> #include<string> #include "bookdata.h" #include "bookinfo.h" #include "invmenu.h" #include "reports.h" #include "cashier.h" using namespace std; const int ARRAYNUM = 20; BookData bookdata[ARRAYNUM]; int main () { bool userChoice = false; while(userChoice == false) { int userInput = 0; bool trueFalse = false; cout << "\n" << setw(45) << "Serendipity Booksellers\n" << setw(39) << "Main Menu\n\n" << "1.Cashier Module\n" << "2.Inventory Database Module\n" << "3.Report Module\n"...
Flow chart of this
program
#include <iostream> #include <cmath> using namespace std; int mainO double sum=0.0, ave-ee, int locmx, locmn int n; cout <<"Enter the number of students: "<<endl; cin >> ni double listln]; double max-0; double min-e; for (int i-e ; i<n ;i++) cout<s enter the gpa: "<cendli cin>>listli]; while (listlile i listli1>4) cout<s error,Try again "<cendl; cin>listlil: sun+=list[i]; N1 if (listli]>max) for(int isin itt) max=list [i]; 10cmx=1+1 ; else if (list [i] min) min=list [i]; locmn-i+1; ave sum/n;...
In this exercise, you will modify the hypotenuse program shown earlier in Figure 9-6. Follow the instructions for starting C++ and viewing the ModifyThis13.cpp file, which is contained in either the Cpp8/Chap09/ModifyThis13 Project folder or the Cpp8/Chap09 folder. Remove both calculation tasks from the main function, and assign both to a program-defined value-returning function named getHypotenuse. Test the program appropriately. //Hypotenuse.cpp - displays the length of a right //triangle's hypotenuse #include <iostream> #include <iomanip> #include <cmath> using namespace std; int...
C++ Check Book Program I need to have a checkbook program that uses the following items. My code that I have appears below. 1) Math operations using built-in math functions 2) Class type in a separate .h file with member functions (accessor functions, get, set, show, display find, etc). There needs to be an overloaded function base/derived classes or a template. 3) Binary File #include <iostream> using namespace std; int main() { double checking,savings; cout<<"Enter the initial checking...
C++ Code error help. I am getting the error: "expression must have a constant value, the value of parameter 'n' ( declared at line 7) cannot be used as a constant" I am also getting this error at lines 65 and 66 with m and n. I do not know how to fix this. Here is my code and ive marked where the errors were with lines: #include<iostream> using namespace std; // Function to allocate memory to blocks as per...