//Source Code to Make color changing in C programming of certain string.
#include<stdio.h>
#include<conio.h>
#include<windows.h>
main()
{
system("cls");
char a;
printf("0 = Black \t8 = Gray \n1 = Blue \t9 = Light Blue\n2 = Green \tA = Light Green \n3 = Aqua \tB = Light Aqua \n4 = Red \tC = Light Red \n5 = Purple \tD = Light Purple \n6 = Yellow \tE = Light Yellow \n7 = White \tF = Bright White");
printf("\n\nChoose a Color : ");
scanf("%s", &a);
switch(a)
{
case '0':
system("color 0");
break;
case '1':
system("color 1");
break;
case '2':
system("color 2");
break;
case '3':
system("color 3");
break;
case '4':
system("color 4");
break;
case '5':
system("color 5");
break;
case '6':
system("color 6");
break;
case '7':
system("color 7");
break;
case '8':
system("color 8");
break;
case '9':
system("color 9");
break;
case 'A':
case 'a':
system("color A");
break;
case 'B':
case 'b':
system("color B");
break;
case 'C':
case 'c':
system("color C");
break;
case 'D':
case 'd':
system("color D");
break;
case 'E':
case 'e':
system("color E");
break;
case 'F':
case 'f':
system("color F");
break;
default:
printf("Invalid Character");
}
getch();
}
No comments:
Post a Comment