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

}



 
 
 

Recent Posts

See All
NIELIT CCC MCQ Questions with Answers

Q1. Which protocol is used to upload and download file? (A) TCP (B) HTTP (C) FTP (D) SMTP Ans: C Q2. How many is Number of digits in a Visa Card number? (A) 15 (B) 16 (C) 18 (D) 19 Ans: B Q3. What is

 
 
 

1 Comment


Algorithm

Like
bottom of page