![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Print colored message with different fonts and sizes in C
C/C++ programming language, the user is provided with functionality to customize the output based on the requirement of the user. C/C++ graphics functions are included in graphics.h header file. Using this library you can create different objects, set the color of text, change the font and size of the text and change the background of the output.
Now, let's see the working of all the function to alter the text of the output in c/c++ programming language −
- setcolor() − This function is used to change the color of the output text.
Syntax
setcolor(int)
Example
#include<stdio.h> #include<graphics.h> int main(){ int gdriver = DETECT,gmode,i; initgraph(&gdriver,&gmode,"C:\Turboc3\BGI"); setcolor(5); return 0; }
- settexttyle() − This function is used to change the font style, orientation, and size of the output text.
Syntax
settexttyle(int style , int orientation , int size);
Example
#include<stdio.h> #include<graphics.h> int main(){ int gdriver = DETECT,gmode,i; initgraph(&gdriver,&gmode,"C:\Turboc3\BGI"); settextstyle(3,1,4); return 0; }
- Outtext − this function is used to print the message passed to it at some certain coordinates(x,y) on the screen.
Syntax
outtext(int x_cordinate , int y_cordinate, text)
Example
#include<stdio.h> #include<graphics.h> int main(){ int gdriver = DETECT,gmode,i; initgraph(&gdriver,&gmode,"C:\Turboc3\BGI"); settextstyle(25,15,’hello!’); return 0; }
- textheight() − this function is used to change the height of the text in the output screen.
Syntax
textheight(int)
- textwidth() − This function is used to change the width of the text in the output screen.
Syntax
textwidth(int)
Advertisements