Skip to content
Related Articles

Related Articles

Improve Article

Print colored message with different fonts and sizes in C

  • Difficulty Level : Easy
  • Last Updated : 29 Oct, 2018

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 :

    Attention reader! All those who say programming isn't for kids, just haven't met the right mentors yet. Join the  Demo Class for First Step to Coding Coursespecifically designed for students of class 8 to 12. 

    The students will get to learn more about the world of programming in these free classes which will definitely help them in making a wise career choice in the future.

  • 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
Recommended Articles
Page :