Program to display color in c and C ++


Program to display color in C and C++

this is the program in c++ , here we used switch statement to print the required color:
'r' and 'R' for Red
'g' and 'G' for Green
'b' and 'B' for blue
else BLACK.


#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
char c;

cout<<"enter the color to print : ";
cin>>c;
switch(c)
{
case 'r': case 'R':
cout<<"RED";
break;
case 'g': case 'G':
cout<<"GREEN";
break;
case 'b': case 'B':
cout<<"Blue";
break;
default:
cout<<"BLACK";
}
}


................................................................................................
Program to display color in c

this is the program in c , here we used switch statement to print the required color:
'r' and 'R' for Red
'g' and 'G' for Green
'b' and 'B' for blue
else BLACK.

.............................................................
#include<stdio.h>
#include<conio.h>
int main()
{
char c;

printf("enter the color to print : ");
scanf("%d",c);
switch(c)
{
case 'r': case 'R':
printf("RED");
break;
case 'g': case 'G':
printf("GREEN");
break;
case 'b': case 'B':
printf("Blue");
break;
default:
printf("BLACK");
}
}

Program to display color in c and c++



Output of :Program to display color in c++:




1 comment:

Powered by Blogger.