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

April 2026
S M T W T F S
 1234
567891011
12131415161718
19202122232425
2627282930