i need a complete C program to draw a sin curve without any application and the output should be displayed in dos prompt. can anyone please help me
Here's a sampleprogram that draws a sine with the SetPixel() function (as Clockowl suggested):
#include<windows.h>
#include<iostream>
#include <cmath>
int main()
{
HWND console = GetConsoleWindow();
HDC dc = GetDC(console);
int pixel =0;
COLORREF C1= RGB(255,0,0); //red
for (double i = 0; i< 6.3; i+=0.05)
{
SetPixel(dc,pixel,(int)(100+50*sin(i)),C1);
pixel+=1;
}
ReleaseDC(console, dc);
std::cin.ignore();
return 0;
}
I remember something about a polyline() function that can connect the dots, but that's for you to research.
Personally I would really recommend to use wxWidgets (or something like it). It has great function for drawing graphs and is platform-independent
Nick Evan
Not a Llama
10,112 posts since Oct 2006
Reputation Points: 4,142
Solved Threads: 403
That's a C++ program btw, not C.
You're absolutely right! I switch between the forums quite a bit and sometimes lose track of where I am :confused:To make it C
Thanks for the effort.
Hoot!
Nick Evan
Not a Llama
10,112 posts since Oct 2006
Reputation Points: 4,142
Solved Threads: 403