Hi,
Can you please help me to solve this problem.
When i entered: 2 6
the will able to generate second of June. But when i tried to execute, there is no response from the program.
can you please advise on when i wanted to add 3 more days to 2 above and able to generate fifth of June.
Please help
2 (day) 6(month) to string Second of June. So far, i am able to convert the following Option 1 and option 2.
This is the code:
#include <stdio.h>
main(){
char *day[] ={"First","Second","Third","Fourth","Fifth","Sixth ","Seventh",
"Eighth","Ninth","Tenth","Eleventh","Twelfth","Thi rteenth",
"Fourteenth","Fifteenth","Sixteenth","Seventeenth" ,
"Eighteenth","Nineteenth","Twentienth","Twenty-First",
"Twenty-Second","Twenty-Third","Twenty-Fourth","Twenty-Fifth",
"Twenty-Sixth","Twenty-Seventh","Twenty-Eighth","Twenty-Ninth",
"Thirtieth","Thirty-First"};
char *month[] ={"January","February","March","April","May",
"June","July","August","September","October",
"November","December"};
int choice;
int dayNum,monthNum,date;
clrscr();
do{
printf("\nMain Menu");
printf("\n1. Convert Day Integer to Date String");
printf("\n2. Convert Month Integer to Month String");
printf("\n3. Convert Date Integer to Date String");
printf("\n\nEnter Choice:");
scanf("%d",&choice);} while((choice < 1) || ( choice >3));
switch(choice){
case 1 : do{
printf("\nEnter Day Integer:");
scanf("%d",&dayNum);
} while ((dayNum<1) ||(dayNum>31));
dayNum--;
printf("\n%s",*(day+dayNum));
break;
case 2 : do{
printf("\nEnter Month Integer:");
scanf("%d",&monthNum);
} while ((monthNum<1) || (monthNum>12));
monthNum--;
printf("\n%s",*(month+monthNum));
break;
case 3 : do{
printf("Enter Date Integer(Day followed by Month):");
scanf("%d,%d",&dayNum,&monthNum);
}while (((dayNum <1) || (dayNum>31)) && ((monthNum<1) || (monthNum>12)));
dayNum--;
monthNum--;
printf("\n%s %s",*(day+dayNum),*(month+monthNum));
break;
break;
default: printf("Invalid selection");
}
getch();
return;
}