xFactorSchool.com(Beta)
How to Do Examples
Python Examples
HTML Examples
Code Examples
C Code Examples
C++ Code Examples
C# Code Examples
Java Code Examples
Python Code Examples
HTML Code Examples
CSS Code Examples
JavaScript Code Examples
Online Editor
C Code Editor
C++ Code Editor
C# Code Editor
Java Code Editor
Python Code Editor
HTML Code Editor
CSS Code Editor
JavaScript Code Editor
Practice how to use switch statement in C
C Online Editor
Execute Code
More C Sample Codes
#include <stdio.h> #include <time.h> int main() { time_t t; struct tm *tm_info; time(&t); tm_info = localtime(&t); //get local time int dayOfWeek = tm_info->tm_wday; //get the day value as integer starting from 0 as Sunday switch (dayOfWeek) { case 0: // if the dayOfWeek = 0 printf("Sunday\n"); break; case 1: // if the dayOfWeek = 1 printf("Monday\n"); break; case 2: // if the dayOfWeek = 2 printf("Tuesday\n"); break; case 3: printf("Wednesday\n"); break; case 4: printf("Thursday\n"); break; case 5: printf("Friday\n"); break; case 6: printf("Saturday\n"); break; default: printf("Invalid day of the week.\n"); break; } return 0; }