Documente Academic
Documente Profesional
Documente Cultură
1(ii) :
Program:
/* Program to calculate a real root of the equation sinx = 5*x - 2 using bisection method */
#include<stdio.h>
#include<math.h>
void main()
{
float f(float);
float a,b,c;
clrscr();
do
{
printf("\nEnter the lower bound of the interval:");
scanf("%f",&a);
printf("\nEnter the upper bound of the interval:");
scanf("%f",&b);
if( f(a) * f(b) >= 0)
{
printf("\nINVALID INTERVAL");
}
}
while( f(a) * f(b) >= 0 );
c=(a+b)/2;
float f( float y)
{
return sin(y) - 5*y + 2;
}