C Program to demonstrate use of break Statement in switch case
The break statement terminates a switch case and transfers control outside the switch statement.
C में break statement किसी matching case को execute करने के बाद switch statement से बाहर निकलता है।
Syntax
break;C Program
#include <stdio.h>int main(){int day;printf("Enter day number (1-7): ");scanf("%d", &day);switch (day){case 1: printf("Monday"); break;case 2: printf("Tuesday"); break;case 3: printf("Wednesday"); break;case 4: printf("Thursday"); break;case 5: printf("Friday"); break;case 6: printf("Saturday"); break;case 7: printf("Sunday"); break;default:printf("Wrong input!");}return 0;}
Output
Enter day number (1-7): 3Wednesday
Explanation
The switch statement checks the value of day and displays the corresponding weekday. The break statement stops execution after the matching case.
switch statement day की value check करके संबंधित दिन display करता है। break statement matching case के बाद execution रोकता है।
Comments
Post a Comment