Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

gotoxy() function :

The gotoxy function is used to to move the cursor to a specified location on the screen. Its Just
Something Other then just Sequential Execution .It moves the cursor with respect to x axis and y
axis. It is very useful when the output is to be displayed at a specified location on the screen.
Working:
The Variable x indicates x-axis. Its Value can be from 0 to 79. The Variable y indicates the y-axis. Its
Value can be from 0 to 24.

Program:
?
1
2
3 #include <cstdlib> // Header Files
4 #include<conio.h> // for getch() function
5 #include <iostream>
#include<windows.h> // Necessary when treating consoles
6 using namespace std;
7 void gotoxy (int x, int y)
8 {
9 COORD coordinates; // coordinates is declared as COORD
10 coordinates.X = x; // defining x-axis
coordinates.Y = y; //defining y-axis
11 SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coordinates);
12 }
13 int main()
14 {
int x;
15
int y;
16
17 cout<<"Enter x: ";
18 cin>>x;
19 cout<<"Enter y: ";
20 cin>>y;
21
gotoxy(x,y); // function call
22 cout<<"C++ Clan Umair Sajid"<<endl;
23 getch();
24 return EXIT_SUCCESS;
25 }
26 </windows.h></iostream></conio.h></cstdlib>
27
28

You might also like