jituTechnology

jituTechnology

write a switch Statement that will examine the value of char type variable called color and print one of the following message, depending upon the character assigned to color.

This is the c source code/program for: write a switch Statement that will examine the value of char type variable called color and print one of the following message, depending upon the character assigned to color.

A. RED, if either r or R assigned to color
B. Green, if either g or G is assigned to color
C. BLUE, if either b or B is assigned to color
D. BLACK, if other character assigned to color
/* a program to enter the character and print its equivalents color
programmed by:
Name : jitendra yadav /
#include <stdio.h>
#include <conio.h>
void main()
{
     char ch;
   printf(“Enter the character “);
   scanf(“%c”,&ch);
   switch(ch)
   {
     case ‘r’:
      case ‘R’:
                printf(“This is red color”);
      break;
      case ‘g’:
      case ‘G’:
                printf(“This is green color”);
      break;
      case ‘b’:
      case ‘B’:
                printf(“This is blue color”);
      break;
      default:
                printf(“This is black”);
   }
   getch();
}

No comments yet.

Add a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.



Connect with Me

GPO 8973 NPC 541; Kathmandu Nepal
Phone: +977 9851236800

Calendar

January 2026
S M T W T F S
 123
45678910
11121314151617
18192021222324
25262728293031