top of page

C Program for Traffic Light using Switch Case

C Program for Traffic Light



#include <stdio.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();

}



2,507 views1 comment

Recent Posts

See All

SQL MCQ Questions and Answers pdf

Q1. SQL stands for A.      Structured Query List B.      Structure Query Language C.      Sample Query Language D.      Both A& B Ans: B Q2. The Subset of SQL commands used to operate Oracle database

DBMS MCQ Questions for Competitive Exams

Q1. What is the full form of DBMS? DBMS का फुल फॉर्म क्या है? A.    Data of Binary Management System B.    Database Management System C.   Database Management Services D.   Data Backup Management Syst

bottom of page