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...

  • 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...

  • 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...

  • 1.Write code for a Java method, printArray, that takes an int array as parameter and prints...

    1.Write code for a Java method, printArray, that takes an int array as parameter and prints it out, one element per line. public static void printArray (int[] values){ Methods that do NOT return a result have “void” as return type. Notice how an array parameter type is passed, int [] }// end printArray 2.Write code for a Java method that takes in as input parameter an integer number, say num, and returns a double array of size num with all...

  • 1. What is the output when you run printIn()? public static void main(String[] args) { if...

    1. What is the output when you run printIn()? public static void main(String[] args) { if (true) { int num = 1; if (num > 0) { num++; } } int num = 1; addOne(num); num = num - 1 System.out.println(num); } public void addOne(int num) { num = num + 1; } 2. When creating an array for primitive data types, the default values are: a. Numeric type b. Char type c. Boolean type d. String type e. Float...

  • 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...

  • Ensure the following compiles 5. Variable scope (1 mark) Some variables are only accessible while executing...

    Ensure the following compiles 5. Variable scope (1 mark) Some variables are only accessible while executing specific code. Global variables are often thought of as evil because the state of a system can be altered making functions execute differently when it isn't expected. There is also the issue of block scope. For an example of block scope, see the file below. Notice that you don't get an error because the code uses the correct syntax. Although the syntax is correct,...

  • 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...

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