Answer to Question #294817 in C++ for fiona

Question #294817

give me an example of gotoxy for loop program in c++


1
Expert's answer
2022-02-07T12:50:23-0500
#include <iostream>
#include <cstdio>
#include <windows.h>
using namespace std;
void gotoxy(int x,int y)//Define a gotoxy yourself and jump the cursor to the x column and y row 
{   
	COORD c; //Define a cursor class
	c.X = x-1; //Set the position of the cursor
	c.Y = y - 1; 
	SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),c); //Call WindowsAPI to set the cursor position
}


int main(){
	for(int i=0;i<10;i++){
		gotoxy(1,i*5+10);
		cout << "Number "<<(i+1);
	}


	cin.get();
	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog