473,394 Members | 1,794 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Trying to draw sin graph in c++

1
This is what I have so far
void TrigFunctions::DrawSine(int degree)
{
int range=0;
int NumLines=16;
double CurrentStep;

//constants
const double sample=0.05;
const double PI=3.1415;
const int FIRSTSTEP=0.5;

//prompt your user for input.
cout << "Please input the range."<<endl;
cin >> range;

//Convert for degree to radians and assign current step a value
CurrentStep= FIRSTSTEP * PI/180;

//get sine values and display graph
for(int i=0;i < NumLines;i++)
{
for(int j =-180;j < 180;j++)
{

/* Compare the sin of the step value to the sin of the sine range value and print '*' if there is a match.
Otherwise, print a blank */
if(sin(CurrentStep) == sin(j* PI/180))
{
cout <<"*"<<endl;
}
else
{
cout <<" ";
}
}

//Increment Current step
CurrentStep += FIRSTSTEP*PI/180;
}


}
Aug 14 '14 #1
1 2185
weaknessforcats
9,208 Expert Mod 8TB
What's your question exactly?

I see the function is named DrawSine and it takes an int argument. Then in the middle it becomes a data entry function to get the range. The function should have no arguments. All it should do id draw the sine with the couts.

The range, degree, NumLines, sample, should be class member variables. These class members can have their own member functions for data entry.

Try to keep your functions doing only one thing.
Aug 14 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: SS KANAGAL | last post by:
Hello, I am drawing a bar graph in an aspx page using System.Drawing namespace . Now I want to provide drill down facility for the graph i.e. on click of a bar in the graph it should get me yet...
4
by: JIM.H. | last post by:
Hello, Is it possible to draw a graph in HTML/APS environment. If not, what classes do I have to draw graph in APS.Net? Any sites as an example? Thanks,
3
by: Bon | last post by:
Hello All I want to draw my own pie chart in MS Access 2000 form. Could anyone tell me where I can find information or sample code on doing it? Cheers Bon
9
by: resmi318 | last post by:
Hi, I am new to coldfusion. I need to query a table to get some datas and then draw a graph using that. Can anyone help me? Thanks Resmi318
1
by: fruityfreak | last post by:
Anyone have any idea on how to draw a line graph with php using the data from mysql.
1
by: mfarooqi | last post by:
I want to draw line graph using vb6. My problem is that data pointds are not fixed but dpendent on some other values so I want to draw graph with variable points. a suggestion or help would be highly...
1
by: Nilam2477 | last post by:
I want to draw a graph similar to microsoft project plan which shows tasks (start & completion date for each task) and dependency like if start of any task is dependent on completion of other tasks. ...
3
by: vipin sharma | last post by:
hello all, i am using netbeans ide for development. I want to display a graph on screen. After some search on google i found that we can create a graph by following steps: 1. extending a class with...
0
by: srinivasng86 | last post by:
hi ,i generated reports using dataset with compact database where i need to give x axis as sample temperature and y axis Emittance values but i am failed to get y axis values i am getting count of...
0
by: luofeiyu | last post by:
can i draw a graph ,such as y=sin(x) in xul ?? can i get some codes about it ? for example:Adding menus and submenus <toolbox> <menubar id="xulschoolhello-menubar"> <menu...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.