Screen related function
1) textcolor() :- textcolor() is an inbuilt function that reside into conio.h and it is responsible to change colour of text (i.e foreground) by specified colour.
Syntax :- To call textcolor()
textcolor(constant/symbolic constant);
For example:-
textcolor(4);
or
textcolor(RED);
NOTE:- An argument passed to inbuilt function textcolor must be constant or symbolic constant(i.e RED).
2) textbackground() :- textbackground() is an inbuilt function that also reside into conio.h and it is responsible to change background color of text by specified colour.
Syntax :- To call textbackground()
textbackground(constant/symbolic constant);
For example:-
textbackground(RED);
or
textbackground(4);
3) cprintf() :- cprintf() is an inbuilt function i.e responsible to display parenthesized statements or monitor and effective its colour according to inbuilt function textcolor() and textbackground().
Syntax :- To call cprintf()
cprintf(“statement”);
For example:-
Explanation (1)
void main()
{
clrscr();
textcolor(4);
textbackground(2);
cprintf(“ welcome to C”);
printf(“\nIt is a demo”);
getch():
}
Output------ welcome to C
It is a demo
Explanation (2):-
void main()
{
clrscr();
textbackground(2);
textcolor(4);
cprintf(“ welcome to C”);
textcolor(5);
cprintf(“\nIt is a demo”);
getch():
}
Output------ welcome to C
It is a demo
Explanation (3):-
void main()
{
clrscr();
textbackground(2);
textcolor(4);
cprintf(“ welcome to C”);
textcolor(1);
cprintf(“\n \rIt is a demo”);
getch():
}
Output------ welcome to C
It is a demo
Explanation (4):-
void main()
{
clrscr();
textbackground(BLUE);
textcolor(RED);
cprintf(“ welcome to C”);
getch():
}
Output------ Error:- Undefined symbol ‘BLUE’
Undefined symbol ‘RED’
NOTE:- To resolve this problem a header file conio.h must be included into file manually.
Explanation (5):-
#include<conio.h>
void main()
{
clrscr();
textbackground(2);
textcolor(4);
cprintf(“ welcome to C”);
getch():
}
Output------ welcome to C
Symbolic constant Constant Background Foreground
BLACK 0 YES YES
BLUE 1 YES YES
GREEN 2 YES YES
CYAN 3 YES YES
RED 4 YES YES
MAGENTA 5 YES YES
BROWN 6 YES YES
LIGHT GREY 7 YES YES
DARK GREY 8 NO YES
LIGHT BLUE 9 NO YES
LIGHT GREEN 10 NO YES
LIGHT CYAN 11 NO YES
LIGHT RED 12 NO YES
LIGHT MAGENTA 13 NO YES
YELLOW 14 NO YES
WHITE 15 NO YES
BLINK 128 NO ***
Comments
Post a Comment