About us

C Program to print your name at the center of the screen

C Program to print your name at the center of the screen

c-program-print-your-name-at-center

IN TURBO IDE


#include<stdio.h>
#include<conio.h>

void main()
{
 int x=80/2,y=25/2;
 clrscr();
 gotoxy(x,y);
 printf("#IncludeHelp");
 getch();
}


In Turbo IDE you can make a simple C Program for print your name at the center of the screen, as above. But in other editors like Codeblocks, it not easy like that because it does not have the definition of gotoxy(), But it has the other function an which you can use.Which is SetConsoleCursorPosition().and the program is:-

In Codeblocks like Editor


#include<stdio.h>
#include<windows.h>

int main()
{
    COORD c;
    c.X=40;
    c.Y=10;
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),c);

/*
SetConsoleCursorPosition(handle,coord); We use (STD_OUTPUT_HANDLE)
Now (STD_OUTPUT_HANDLE) will return the handle that will use to handle output on the screen
*/
    
    printf("#IncludeHelp");
    return 0;

}





You can also visit:-