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

}



397 views0 comments

Recent Posts

See All

1. The output of the following code. string=”my name is x” for i in string: print(i,end=”,”) A. m,y,,n,a,m,e,,i,s,x, B. m,y,,n,a,m,e,,i,s,x C. my,name,is,x D. None Answer: (A) 2. What arit

1. What is the full form of IoT? A. Internet of Technology B. Incorporate of Things C. Internet of Things D. Incorporate of Technology Answer: C 2. How many numbers of the element

bottom of page