#include<iostream>
#include<graphics.h>usingnamespacestd;intmain(){intgd=DETECT,gm;floatx=0,y,a;LOOP:cout<<"\nEnter the Amplitude value ";cin>>a;if(a>=30&&a<=200){initgraph(&gd,&gm,NULL);line(0,230,620,230);for(x=0;x<=600;x++){y=230+(120*sin(2*3.14*x/200));x=x+3;putpixel(x,y,14);outtextxy(x,y,(char*)"o");setcolor(2);line(x,y,x,230);delay(50);}delay(3000);}else{cout<<"\n------------------------------------------------";cout<<"\nAmplitude must be in the range of [30-200]";cout<<"\n------------------------------------------------";gotoLOOP;}return0;}
Output
godarda@gd:~$ g++ gd.cpp -lgraph godarda@gd:~$ ./a.out
Enter the Amplitude value 100
Dear User, Thank you for visitng GoDarda. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.