#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{ clrscr();
int x,x1,y,y1,i=0;
x=x1=35; y=y1=12;
cout<<”\t Starting point ( 35,12 ).\n\t Starting point is notified by * “;
char *comm;
cout<<”\n\tGive your command:”;
cin>>comm;
gotoxy(x,y);
cout<<”*”;
while(comm[i]!=’ ‘)
{ if(comm[i]==’n’)
{ y–;
gotoxy(x,y);
cout<<”n”;
}
if(comm[i]==’s’)
{ x++;
gotoxy(x,y);
cout<<”s”;
}
if(comm[i]==’e’)
{ y++;
gotoxy(x,y);
cout<<”e”;
}
if(comm[i]==’w’)
{ x–;
gotoxy(x,y);
cout<<”w”;
}
i++;
}
cout<<”\n\tEnd point ( “<<x<<” , “<<y<<” )”;
float dist=sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1));
gotoxy(9,16);
cout<<”Total distance : “<<dist;
getch();
}
