write a java program to accept a number from user and print the corresponding colour RGB according to it
Answers
#include <stdio.h>
void main()
{
char color;
clrscr();
printf("Enter character (R/G/B): ");
color= getchar();
switch (color)
{
case 'R':
printf ("Red") ;
break;
case 'G':
printf("Green");
break;
case 'B':
printf("Blue");
break;
}
getch();
}
hope it helps you!
Answer:
I hope it is helpful.
Explanation:
Switch (val)
{
Case 1:
System.out.println("color is red");
break;
Case 2:
System.out.println("color is green");
break;
Case 3:
System.out.prinln("color is blue");
break;
default:
System.out.println(Wrong choice")
}