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
  • Write an interactive program exam1 that loops Loop and asks the user at the end of...

    Write an interactive program exam1 that loops Loop and asks the user at the end of the loop to continue or not Ask the user to enter an alphanumeric US phone number Read the line of text from the screen Check if the entered string is a valid phone number using isValid(Line) if it is valid number { call toNumeric(line) to convert it to digits print Line after conversion } bool isValid(char line[]) { //st must have 10 digits and...

  • 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 functions in C++ that asks for and return the following: 1. The...

    I need help writing functions in C++ that asks for and return the following: 1. The amount of any car rentals 2.Miles driven, if a private vehicle was used. Vehicle expense is 0.27 $ per mile driven. 3.Parking fees.(The company allows up to 6 per day. Anything in excess of this must be paid by the employee), 4. Taxi fees(The company allows up to 10$ per day, for each day that taxi was used. Anything in excess must be paid...

  • 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 stephen.marquard@uct.ac.za 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...

  • C++ Programming I have finished the code but there's one error which shows that "strcpy" might...

    C++ Programming I have finished the code but there's one error which shows that "strcpy" might be unsafe. Consider using strcpy_s instead. I've tried that but it's not working probably because I didn't implement it correctly. I am posting my code below. It'd be really helpful if you could fix all the strcpy errors and post it below. Thank you. Text.cpp: #include <iostream> #include <iomanip> #include <cassert> #include <cstring> #include "Text.h" Text::Text ( const char *charSeq ) {    bufferSize...

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

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