top of page

C Program for Traffic Light using Switch Case

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();

}



3,042 views1 comment

1 comentário


Lakshmi sree Kesanapalli
Lakshmi sree Kesanapalli
24 de nov. de 2023

Algorithm

Curtir
bottom of page