2
Changing Text color in C/C++ Language

Hi Friends Today i am Writing a Tut on changing text color in C / C++ language using Visual C/C++  , Turbo C++ and Dev C++ 

What To Do?


Simple Open your C/C++ IDE

Write Your Program

Then Use This Function system("color xy");  Located in stdlib.h  header file #include<stdlib.h>. 

where x = background  color  and y = foreground 

Note: Both Color could Never  b same.

This trick will work on windows console because using system("");  we can use any DOS command.

Basically color is a command of command prompt as we know our C/C++ console projects run on windows console in Visual C/C++  and Dev C++

 

  • 0 = Black
  • 1 = Blue
  • 2 = Green
  • 3 = Aqua
  • 4 = Red
  • 5 = Purple
  • 6 = Yellow
  • 7 = White
  • 8 = Gray
  • 9 = Light Blue
  • A = Light Green
  • B = Light Aqua
  • C = Light Red
  • D = Light Purple
  • E = Light Yellow
  • F = Bright White

In Command prompt you can also change the text color by just typing color xy;

where x=background  color and y=foreground color

Colors are given in the above picture.

To Understand  it well lets take make a simple program





Post a Comment

  1. Useful Program!
    Thanks for posting it! Its been a good help for me!

    ReplyDelete
  2. #include
    #include
    int main (void)
    {
    float average;
    int i,sum,count;
    count=0;
    sum=0;
    system("color AC");
    printf ("Enter a number 786 to end loop");
    scanf ("%d",&i);
    while (i!=786);
    {
    sum=sum+i;
    printf ("Enter a number 7886 to end loop");
    scanf ("%d",&i);
    count=count+1;
    }
    average=(float) sum/count;
    printf ("Average of %d numbers are = %.2f", count,average);

    ReplyDelete

 
Top