Sunday, December 6, 2015

Text and Background color print in C Program

Program #14

Description:
Set text color as well background color in C Program.

#include<stdio.h>
#include<conio.h>
int main(void)
{
   int i;

   clrscr();
   for (i=0; i<15; i++)
   {

       /* Just positioning to center */
       gotoxy(30,i+1);

       cprintf("Let Us C");
       cprintf("\r\n");
   
    /* set text color */
       textcolor(i+1);
   
    /* set background color */
       textbackground(i);
   }

   getch();
   return 0;
}



4 comments:

  1. In this program the gotoxy is used to mention the axis?

    In for loop if i give the value for i<20 it print the upto 20 different colors?

    ReplyDelete
  2. Yes, gotoxy() funtion used to position the cursor. But we can't increase i value to get 20 different colors. Same colors will get repeated. Just try 20 and run it!!

    ReplyDelete
    Replies
    1. yes, I have try it i value upto 30 then i get only the repeated colors only that's you are right.

      Delete
  3. Yes, gotoxy() funtion used to position the cursor. But we can't increase i value to get 20 different colors. Same colors will get repeated. Just try 20 and run it!!

    ReplyDelete

Popular Posts