The logic of sinc function.

closed account (oLNTURfi)
I'm having trouble with a problem. The problem asks that I use the sinx/x function and produce a table of values for the function on a user entered interval. I'm just starting out with C++ and having a hard time with this so any help would be greatly appreciated. Here's what I have so far:
#include <iostream>
#include <cmath>

using namespace std;


double sinc(const double x)




int main()
{
{
if (x==0)
return 1;
return sin(x)/x;

}

double a,b


cout<<"Enter the values for the interval with"<<"\na = starting value"<<"\nb = ending value"<<endl;
cout<<"a = "
cin>>a>>endl;
cout<<"b = "
cin>>b>>endl;

do sinc(x);
for (x = a; x<= b; x ++)
cout<<"_____________________________________";
cout<<"\n "<< a << " "<< sinc(a)

}

What I want to do is have the data displayed in a table with values of x displayed on corresponding line with function value at the x value
1
2
3
4
5
6
7
8
9
10
11
double sinc(const double x)

int main()
{
{
if (x==0)
return 1;
return sin(x)/x;

}
//... 
did you mean:
1
2
3
4
5
6
7
8
9
10
double sinc(const double x)
{
    if (x==0)
        return 1;
    return sin(x)/x;
}

int main()
{
    //... 



1
2
3
4
do sinc(x);
for (x = a; x<= b; x ++)
cout<<"_____________________________________";
cout<<"\n "<< a << " "<< sinc(a)
did you mean:
1
2
3
4
5
for (double x = a; x<= b; x ++)
{
    cout<<"_____________________________________";
    cout<<"\n "<< x << " "<< sinc(x);
}
Last edited on
closed account (oLNTURfi)
Yes, but additionally how would I continue the table for the interval?
Topic archived. No new replies allowed.