#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
kodingwindow@kw:~$ g++ kw.cpp -lgraph kodingwindow@kw:~$ ./a.out
Enter the Amplitude value 100
Dear User, Thank you for visitng KodingWindow. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.