top of page

C Program for Traffic Light using Switch Case

  • Writer: Rajesh Singh
    Rajesh Singh
  • Aug 26, 2022
  • 1 min read

C Program for Traffic Light



#include <stdio.h>

#include<conio.h>

Void main ()

{

char colour;

printf ("Enter the colour of the light (R,G,Y): ");

scanf ("%c", &colour);

switch (colour)

{

case 'R':

case 'r':

printf ("STOP \n");

break;

case 'Y':

case 'y':

printf ("WAIT\n");

break;

case 'G':

case 'g':

printf ("GO \n");

break;

default:

printf ("The colour is not valid \n");

}


getch();

}



 
 
 

Recent Posts

See All
IT Tools and Network Basics Test

Q1. Presentation file created in LibreOffice Impress is saved with the extension….   लिब्रे ऑफिस इंप्रेस में बनाई गई प्रेजेंटेशन फ़ाइल एक्सटेंशन के साथ सेव की जाती है .ods .odt .ott .odp Ans: D Q2. So

 
 
 

1 Comment


Lakshmi sree Kesanapalli
Lakshmi sree Kesanapalli
Nov 24, 2023

Algorithm

Like
bottom of page