Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9288189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T19:51:38+00:00 2026-06-18T19:51:38+00:00

I’m working on an integration program using [right] rectangle sums. I am using the

  • 0

I’m working on an integration program using [right] rectangle sums. I am using the beginning bound as a=1, using ‘n’ as the # of rectangles, and ‘inc’ as the increment that increases z. Here is the code I have so far:

#include <iostream>
#include <cmath>

using std::cout;
using std::endl;
using std::cin;

int main(){

    int n;
    float b;
    float z;
    z=((b-1)/n);
    float inc;
    float new_sum;
    float sum;
    int decision;


    cout << "Would you like to calculate an area? " << endl;
    cout << "Enter 1 for yes, 0 for no: " << endl;
    cin >> decision;

    cout << "Please enter the number of rectangles you would like to use: " << endl;
    cin >> n;
    cout << "Please enter the upper bound of integration: " << endl;
    cin >> b;

    for (inc=0; inc < b; inc++){
        new_sum=z*(f(1+(inc*z)));
        sum=sum+new_sum;
    }

    cout << sum << endl;

return 0;

}

I have two questions:

  1. How do I use the function f(x)=x^5 + 10 in this? I’m not sure how it should be inputted and formatted in the for loop.

  2. How do I loop the first question sequence (Would you like to calculate an area?), using a for loop, to repeat until the user enters 1 for yes (I know how to do this with a while loop, but was wondering how it would be done with a for loop?)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T19:51:39+00:00Added an answer on June 18, 2026 at 7:51 pm

    How do I use the function f(x)=x^5 + 10 in this? I’m not sure how it should be inputted and formatted in the for loop.

    float f( float x ) {
        return pow( x, 5 ) + 10; // maybe x * x * x * x * x + 10
    }
    

    add this lines before function main definition.

    How do I loop the first question sequence (Would you like to calculate an area?), using a for loop, to repeat until the user enters 1 for yes (I know how to do this with a while loop, but was wondering how it would be done with a for loop?)

    for (;;) {
        cout << "Would you like to calculate an area? " << endl;
        cout << "Enter 1 for yes, 0 for no: " << endl;
        cin >> decision;
        if ( decision != 1 ) // or if ( decision == 0 )
        {
            break;
        }
    
        cout << "Please enter the number of rectangles you would like to use: " << endl;
        cin >> n;
        cout << "Please enter the upper bound of integration: " << endl;
        cin >> b;
    
        for (inc=0; inc < b; inc++){
            new_sum=z*(f(1+(inc*z)));
            sum=sum+new_sum;
        }
    
        cout << sum << endl;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am using JSon response to parse title,date content and thumbnail images and place
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.