Question

double sinLoops (double x) { int i = 7; //this didnt exist. double result = 1/(m+1) // line 3 double pi=3.14; //You need the

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

*Please follow the comments to better understand the code.

**Please look at the Screenshot below and use this code to copy-paste.

***The code in the below screenshot is neatly indented for better understanding.



This is a very big question.
I have solved all of them. 
Please give me an upvote dear, Much Appreciated.!!



PLEASE FIND THE ANSWERS IN THE COMMENTS:


    double sinLoops(double x) {
        int i=7;
        
        // Question1: Even if we insert a ; at the end, we didn't have any variable m
        // So, we will get an error saying "Cannot resolve symbol 'm' ".
        double result = 1/(m+1); 
        double pi=3.14;
        do {
            double num=x;
            double fac=1;
            /*  Question2: This loop calculates the value of "Twice the value of i"
                It starts from 1 and ends at 2*i +1 
                Example: ==> if i=2, it repeats for: i=1 to 2*2 +1 = 5(Not included)
                    counter=1,2,3,4
                    ==> if i=3, it repeats for: i=1 to 2*3 +1 = 7(Not included)
                    counter=1,2,3,4,5,6
            */
            for(int counter=1; counter<(2*i+1); counter++) {
                
            }
            for(int counter2=(2*i+1); counter2>=1; counter2--) {
                fac *= counter2;
            }
            /* Question3: The evaluation is done like this step by step:
                STEP1: Check the operator precedence of * /
                STEP2: Since, both * and / has the same precedence, evaluate left to right
                STEP3: So, evaluate num1*num2 and then divide (num1*num2) / fac
            */
            element = num1 * num2 / fac;
            result += element;
            i++;
        }while(element > 0.0000001 || element<-0.0000001);
        /*
        Question4:  This Function will NOT return anything. 
                    It results in the compile time error.
                    So, It Does Not Get that far.
         */
    }

/* Question5: What does this function do?
   Answer:    This function is supposed to calculate the sin value of a value.
              Like sin(x)

 */

1 2 public class CounterDemo { double sinLoops(double x) { int i=7; 3 4 5 6 7 8 9 Il Question1: Even if we insert a ; at the33 34 35 }while(element > 0.0000001 || element<-0.0000001); /* Question4: This Function will NOT return anything. It results

If there are any doubts, comment down here. We are right here to help you. Happy Learning..!! PLEASE give an UPVOTE I Have Pu

Add a comment
Know the answer?
Add Answer to:
double sinLoops (double x) { int i = 7; //this didn't exist. double result = 1/(m+1)...
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
  • Language= c++ 1 C++ function • Yes this was written by a senior in one of...

    Language= c++ 1 C++ function • Yes this was written by a senior in one of my 300-level classes. • I realized instantly this was HW50 in front of me. double sinLoops (double x) { int i = 7; //this didn't exist. double result = 1/(m+1) // line 3 double pi=3.14; //You need the individual taylor series element. do { double num = x; //these need to be reset each time. double fac 1; //if not they overflow and infinity/infinity...

  • C++ problem where should I do overflow part? in this code do not write a new...

    C++ problem where should I do overflow part? in this code do not write a new code for me please /////////////////// // this program read two number from the user // and display the sum of the number #include <iostream> #include <string> using namespace std; const int MAX_DIGITS = 10; //10 digits void input_number(char num[MAX_DIGITS]); void output_number(char num[MAX_DIGITS]); void add(char num1[MAX_DIGITS], char num2[MAX_DIGITS], char result[MAX_DIGITS], int &base); int main() { // declare the array = {'0'} char num1[MAX_DIGITS] ={'0'}; char...

  • What does this function do? int mystery(double employees[], double id, int size) { for (int i...

    What does this function do? int mystery(double employees[], double id, int size) { for (int i = 0; i < size; i++) { if (id == employees[i]) { return i; } } return -1; } A. This is a function that performs a search. If the id is found in the employees array, its index location is returned, otherwise -1 is returned. B. This is a function that sorts the employees array C. This is a function that returns all...

  • My code is not doing what I want it to do and I can't seem to...

    My code is not doing what I want it to do and I can't seem to figure out why it's not working. I commented some of the code to give some context to what I'm trying to do. Can someone check to see where my code is off. I'm assuming that I didn't use the counters properly or I'm using the pointers incorrectly. I can only use pointers to do this by the way. Code: #include <iostream> using namespace std;...

  • Please, explain clearly each line of code with your answers. Question 1 Consider the following code...

    Please, explain clearly each line of code with your answers. Question 1 Consider the following code snippet: int ctr = 0; int myarray[3]; for (int i = 0; i < 3; i++) { myarray[i] = ctr; ctr = ctr + i; } cout << myarray[2]; What is the output of the code snippet? Question 2 Consider the following code snippet: int cnt = 0; int numarray[2][3]; for (int i = 0; i < 3; i++) {   for (int j =...

  • QUESTION 1 Using the following declarations and a member of the Array class, int [ ]...

    QUESTION 1 Using the following declarations and a member of the Array class, int [ ] bArray = new int [10]; int location; Using a method in the Array class, write a statement that would change the order of the elements in the bArray array. The contents of the first cell should hold what was in the last cell. The second cell should hold what was in the next to last cell. __________________________ HINT: You must write the full statement...

  • Need help with this C++ homework I need help problem 1-9 that possible if my wish?...

    Need help with this C++ homework I need help problem 1-9 that possible if my wish? Thank you friend Tiet WRITE FUNCTION PROTOTYPES for the following functions. The functions are described below on page 2. (Just write the prototypes) When necessary, use the variables declared below in maino. mm 1.) showMenu m2.) getChoice 3.) calcResult m.) showResult 5.) getInfo mm.) showName 7.) calcSquare 8.) ispositive int main { USE THESE VARIABLES, when needed, to write function prototypes (#1 - #8)...

  • 1. Answer the questions considering the following functions headers: int func1(int x, double w) double func2(string...

    1. Answer the questions considering the following functions headers: int func1(int x, double w) double func2(string I, int y, double r) char func3(int z, int s, double t, char a) a. How many parameters does function func1 have? What is the type of function func1? b. How many parameters does function func2 have? What is the type of function func22 c. How many parameters does function func3 have? What is the type of function func3? d. Write a C++ statement...

  • Code that needs to be modified: #include #include #include int main() { int i,N,x; unsigned int seed; double R; printf("\nEnter number of iterations and seed"); printf("\n"); scanf(&#3...

    Code that needs to be modified: #include #include #include int main() { int i,N,x; unsigned int seed; double R; printf("\nEnter number of iterations and seed"); printf("\n"); scanf("%i %u", &N,&seed); srand(seed);    for(i=0;i { R=(double)rand()/RAND_MAX; if (R<0.5) x=x+1; else x=x-1; } printf("Final location is "); printf("%d",x); printf("\n"); } Question: Write a code that generates N pairs of random numbers. Call the first member of each pair x and the second member y. Count how many of the N pairs obey x^2+y^2<1. Call...

  • Question 1 What is the value of x after the following int x = 5; x++;...

    Question 1 What is the value of x after the following int x = 5; x++; x++; x+=x++; A)14 B)10 C)13 D)15 Question 2 The last line in value returning function (before the }) should contain the word return. True False Question 3 This contains three parts: Void or Data Type the name optional parameter list A)Menu System B)Function Header C)Switch Question 4 What is a variable? A)a pointer B)a place in memory to hold data C)int D)a computer programming...

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