6 Write a program to perform the following a Turn on pilot l
6. Write a program to perform the following:
a. Turn on pilot light 1 (PL1) if the thumbwheel switch value is less than 4.
b. Turn on pilot light 2 (PL2) if the thumbwheel switch value is equal to 4.
c. Turn on pilot light 3 (PL3) if the thumbwheel switch value is greater than 4.
d. Turn on pilot light 4 (PL4) if the thumbwheel switch value is less than or equal to 4.
e. Turn on pilot light 5 (PL5) if the thumbwheel switch value is greater than or equal to 4.
Solution
I am writing this answer in C Program
#include <stdio.h>
int main(void) {
int switch_value;
printf(\"Enter the Thumbwheel Switch Value\");
scanf(\"%d\",&switch_value);
if(switch_value<4)
printf(\"Turn ON Pilot light PL1\");
else if(switch_value == 4)
printf(\"Turn ON Pilot Light PL2\");
else if(switch_value > 4)
printf(\"Turn ON Pilot Light PL3\");
else if(switch_value <= 4)
printf(\"Turn ON Pilot Light PL4\");
else if(switch_value >= 4)
printf(\"Turn ON Pilot Light PL5\");
else
printf(\"Enter the correct Switch value\");
return 0;
}
