Question

Having trouble writing this code in C++. It asks to convert the for loops. I tried...

Having trouble writing this code in C++. It asks to convert the for loops. I tried it myself but I don't think I am doing it right, please help fix.

Edit: this is the whole question...It just asks to make the following changes to the for loops..

Question:

Write and "convert" the i and j for loops as follows:
* i must start at ilow,
* i's for loop will terminate at ihigh,
* j must start at jlow,
* j's for loop will terminate at jhigh.

i and j for loops:

for (size_t i{}; i != image_width; ++i)
{
    Real const x =
      image_index_to_real(i, image_width,
        point_width.real(), min_point.real());
    ;
    for (size_t j{}; j != image_height; ++j)
    {
      Real const y =
        image_index_to_real(j, image_height,
          point_width.imag(), min_point.imag());
      ;
      complex const c(x,y);
      image(i,j) = m2c(compute_mandelbrot_at(c,max_iter),max_iter);
    }
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1
 //ilow and jlow for loops: #include<iostream> using namespace std; int main() { for (size_t ilow{}; ilow != image_width; ++ilow) { Real const x = image_index_to_real(ilow, image_width, point_width.real(), max_point.real()); ; for (size_t jlow{}; jlow != image_height; ++jlow) { Real const y = image_index_to_real(jlow, image_height, point_width.imag(), max_point.imag()); ; complex const c(x,y); image(ihigh,jhigh) = m2c(compute_mandelbrot_at(c,max_iter),max_iter); } } return 0; }
Add a comment
Know the answer?
Add Answer to:
Having trouble writing this code in C++. It asks to convert the for loops. I tried...
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
  • I am having some trouble writing this program. In C language Write a program which asks...

    I am having some trouble writing this program. In C language Write a program which asks user 1) number of sets (integer input), followed by 2) number of sides of a dice (integer input) and 3) number of dices (integer input). number of sets mean how many times this process is going to repeat, number of sides mean total number of sides in a dice (usually 6) and number of dices mean how many number of dices we’re going to...

  • I need help writing a code to solve this problem. The question asks "What position does...

    I need help writing a code to solve this problem. The question asks "What position does each man fill? Submit a listing(code), and the output of your program" (1) (20pts) Write programs in Python or C++ to to solve the following problem: Steve, John and Luke make their living as carpenter, painter and plumber, though not necessarily respectively. • The painter recently tried to get the carpenter to do some work for him, but was told that the carpenter was...

  • I am new to Python and am having trouble coming up with writing code to the...

    I am new to Python and am having trouble coming up with writing code to the following problem... The program must: Prompt for a file name Opens that file and reads through the file Displays a custom error message if the file does not exist You can pull the hour out from the 'From ' line by finding the time and then splitting the string a second time using a colon. From [email protected] Sat Jan 5 09:14:16 2008 Accumulated the...

  • I am having trouble understanding how this code is able to use the contents of the...

    I am having trouble understanding how this code is able to use the contents of the header file. Can someone please provide comments in the main code to describe what is happening? (especially on the bool isNumber) THE MAIN CODE: #include<bits/stdc++.h> #include "MyCartesianPoint.h" #include <math.h> #include <iostream> using namespace std; bool isNumber(string s) {    if(!isdigit (s[0]))    {        if(s[0] != '-')        return false;               else if(s.length() == 1)        return false;...

  • I am having trouble understanding how this code is able to use the contents of the...

    I am having trouble understanding how this code is able to use the contents of the header file. Can someone please provide brief comments in the top code to show what is happening? THE CODE: #include<bits/stdc++.h> #include "MyCartesianPoint.h" #include <math.h> #include <iostream> using namespace std; bool isNumber(string s) {    if(!isdigit (s[0]))    {        if(s[0] != '-')        return false;               else if(s.length() == 1)        return false;    }       for...

  • I need help with writing the for loops required to calculate c and d in Matlab...

    I need help with writing the for loops required to calculate c and d in Matlab Files い2》 New Magma moving int ! Brick Oven-Google Ma 办Calculate summation us」 Home Chegg.com × x × × ← -> d 을 Secure https://utexas.instructure.com/courses/1 207025/files/folder/Homework/Hw4?preview-43392926 HW4.pdf Download ⓘInfo ×Close -ZOOM rodut Using Loops: Consider the following vector, , and matrices, A and B z=[0 1 1-5 2012 22]. Dashboa Calculate the following by hand and then write (by hand) the equivalent MATLAB loop:...

  • C++: Need help debugging my code I am writing this and using some other examples as reference code while rewriting it with my own understanding of the material but am having trouble making it finally...

    C++: Need help debugging my code I am writing this and using some other examples as reference code while rewriting it with my own understanding of the material but am having trouble making it finally compile. Below is a picture of the error messages. //main.cpp //Semester Project //Created by J---on 5/6/2019 #include <iostream> #include <fstream> #include <string> #include <sstream> #include <bits/stdc++.h> using namespace std; void instructions(); //displays program details and instructions void openFile(); void takeInput(int*); void switchBoard(int*); struct price {...

  • Java Programming Question. I am writing a code to calculate the roots of the quadratic equation...

    Java Programming Question. I am writing a code to calculate the roots of the quadratic equation based on the values of the coefficients A, B, and C. I am supposed to enter 5 values for each coefficient, and the output should be five different answers (see example) using a for loop and if else statements. However, when I run my code, I am only able to enter one value for each coefficient and the output is one answer repeated five...

  • Hello, I am having trouble with this C++ programming assignment. If someone could write the code...

    Hello, I am having trouble with this C++ programming assignment. If someone could write the code or at least part of it that would help me, because every code I try has errors. Using if Statements, Loops and Nested Loops • Scanning Characters in a String Using a Loop • Performing Character Arithmetic In project, you will write an interactive program that, counts the number of digits in a non-negative integer, factorizes the integer into powers of ten and its...

  • c++, I am having trouble getting my program to compile, any help would be appreciated. #include...

    c++, I am having trouble getting my program to compile, any help would be appreciated. #include <iostream> #include <string> #include <string.h> #include <fstream> #include <stdlib.h> using namespace std; struct record { char artist[50]; char title[50]; char year[50]; }; class CD { //private members declared private: string artist; //asks for string string title; // asks for string int yearReleased; //asks for integer //public members declared public: CD(); CD(string,string,int); void setArtist(string); void setTitle(string); void setYearReleased(int); string getArtist() const; string getTitle() const; int...

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