Skip to content
Related Articles
Open in App
Not now

Related Articles

Print colored message with different fonts and sizes in C

Improve Article
Save Article
  • Difficulty Level : Medium
  • Last Updated : 29 Oct, 2018
Improve Article
Save Article

In C/C++ we can use graphics.h header file for creation of programs which uses graphical functions like creating different objects, setting the color of text, printing messages in different fonts and size, changing the background of our output console and much more.
Here we will create a program which will print message (“geeks”) in colored form in different font style and size. listed below are some function used :

  • setcolor(): It will set the cursor color and hence anything written on the output screen will be of the color as per setcolor().
    function prototype :

  • settexttyle(): It set the text font style, its orientation(horizontal/ vertical) and size of font.
    Function prototype :

    settextstyle(int style, int orientation, int size);
  • outtextxy() : It will print message passed to it at some certain coordinate (x,y).
    function prototype :

    settextstyle(int style, int orientation, int size);
  • More functions:






Note: Given program will not run on IDE, try it on your compiler

// C program to print
// message as colored characters
// function for printing
// message as colored character
void printMsg()
    // auto detection
    int gdriver = DETECT,gmode,i;
    // initialize graphics mode
    for (i=3; i<7; i++)
        // setcolor of cursor
        // set text style as
        // settextstyle(font, orientation, size)
        // print text at coordinate x,y;
// driver program
int main()
    return 0;



This article is contributed by Shivam Pradhan (anuj_charm). If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!