0% found this document useful (0 votes)
39 views5 pages

Case Problem #2 FEBRUARY 21, 2017: Deonisis R. Versola Data Structure & Algo Analysis Bscpe-Iii Engr. Jermine Valen

The document contains code for two programs that take user input of a number (day or month) and output the corresponding day of the week or month. The first program takes a number from 1-7 and outputs the day of the week. The second takes a number from 1-12 and outputs the month. Both programs validate the input and return an error message for invalid numbers.

Uploaded by

Deonisis Versola
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views5 pages

Case Problem #2 FEBRUARY 21, 2017: Deonisis R. Versola Data Structure & Algo Analysis Bscpe-Iii Engr. Jermine Valen

The document contains code for two programs that take user input of a number (day or month) and output the corresponding day of the week or month. The first program takes a number from 1-7 and outputs the day of the week. The second takes a number from 1-12 and outputs the month. Both programs validate the input and return an error message for invalid numbers.

Uploaded by

Deonisis Versola
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

DATA STRUCTURE & ALGO

DEONISIS R. VERSOLA
ANALYSIS
BSCPE-III ENGR. JERMINE VALEN

CASE PROBLEM #2

FEBRUARY 21, 2017


3.

#include <stdio.h>
main()
{
int day;

printf ("Enter Day Number (1 = Sunday to 7 = Saturday)\n");


scanf ("%d", &day);

if (day < 1 || day > 7)


{
printf ("Invalid Input !!!!\n");
return 0;
}

if (day == 1)
{
printf ("Sunday\n");
}
else if (day == 2)
{
printf ("Monday\n");
}
else if (day == 3)
{
printf ("Tuesday\n");
}
else if (day == 4)
{
printf ("Wednesday\n");
}
else if (day == 5)
{
printf ("Thursday\n");
}
else if (day == 6)
{
printf ("Friday\n");
}
else if (day == 7)
{
printf ("Saturday\n");
}
return 0;
}
4.

#include <stdio.h>
main()
{
int month;

printf ("Enter the number of month (1 = January to 12 = December)\n");


scanf ("%d", &month);

if (month < 1 || month > 12)


{
printf ("Invalid Input !!!!\n");
return 0;
}

if (month == 1)
{
printf ("January\n");
}
else if (month == 2)
{
printf ("February\n");
}
else if (month == 3)
{
printf ("March\n");
}
else if (month == 4)
{
printf ("April\n");
}
else if (month == 5)
{
printf ("May\n");
}
else if (month == 6)
{
printf ("June\n");
}
else if (month == 7)
{
printf ("July\n");
}
else if (month == 8)
{
printf ("August\n");
}
else if (month == 9)
{
printf ("September\n");
}
else if (month == 10)
{
printf ("October\n");
}
else if (month == 11)
{
printf ("November\n");
}
else if (month == 12)
{
printf ("December\n");
}

return 0;
}

You might also like