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 7979089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:40:37+00:00 2026-06-04T09:40:37+00:00

this code is an Integral program that calculate functions f(x) and here .. the

  • 0

this code is an Integral program that calculate functions f(x)

and here .. the function is f(x)= x^2

int main()
{
float integral;
float a=0,b=0;
int n=1024;
float h;
float x;
int i;

float f(float x);

printf("Enter a, b \n");
scanf("%f %f" , &a, &b);
printf("Enter  n\n");
scanf("%d" , &n);



h=(b-a)/n;
integral = (f(a)+f(b))/2;
x=a;
for (i = 0; i <= n-1; n++)
{
    x = x + h;
    integral = integral + f(x);
}
integral = integral * h ;

printf("with n = %d trapezoids, our esrimate\n", n );
printf("of the integral from %f to %f =  %f\n", a , b , integral);

system("pause");
return 0;

}


float f(float x)
{
  return x*x;
}

the output of n always garbage .. i don’t know why
where is my wrong ??

the question is stupid

bu i really tired looking for the wrong
enter image description here

  • 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-04T09:40:39+00:00Added an answer on June 4, 2026 at 9:40 am

    Here’s your error: for (i = 0; i <= n-1; n++). You increment n instead of i.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This code: $(#permalink a).click(function(id){ var id = this.getAttribute('href'); $(#newPostContent).load(id, function() { $(#removeTrigger).click(function() { $(#removeThis).hideToggle();
I have a loop in my C++/OpenMP code that looks like this: #pragma omp
I did this code: from scitools.std import * from sympy import * x=Symbol('x') #Integral
I have a code, that was not made by me. In this complex code,
I have a function in a module that looks something like this: module MyLibrary
My instructor sent me this code, which is supposed to be an integral part
When I try and compile this program, I get errors (included below the code)
I created a simple integral function and DFT function that I can use with
This Code: Something = new Guid() is returning: 00000000-0000-0000-0000-000000000000 all the time and I
This code gives me an empty result. I expect it to print out the

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.