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

}



1,419 views0 comments

Recent Posts

See All

1. Which of the following is not a control structure? A. Loop B. Process C. Decision. D. None of these Answer: () 2. For performing the addition of two numbers, which of the following symb

Q1. The purpose of communication is to help officials to -----------------the employees. A. Eliminate B. Motivate C. Threaten D. Apprise Ans: B Q2. What is the number of elements i

Red Fort The Red Fort is a verifiable stronghold in the national capital of New Delhi. Situated in the focal point of the city, it was the principle living arrangement of the rulers of the Mughal line

bottom of page