need a function when given an int between 0 and 6 prints the day of the week need help plzzzzzzzzzzzzzzzz
Printable View
need a function when given an int between 0 and 6 prints the day of the week need help plzzzzzzzzzzzzzzzz
Get writing your own stuff.... post here when you have problems coding it. Show a little effort and people will be willing to help you.
Read the guidelines about homework.
i just need a little bust start i dont really no what to do really new just need some plzzzzzzzzzzzzzzz
thjis dealing with the fuction probleum plz help
Why don't you start with a tutorial, or maybe a good C++ book.
There are various ways to do what you're asking, why not do a bit of research yourself and see what you can come up with.
edit: the stupid thing has messed up the string literal slightly. it should read
"SundayMondayTuesdayWednesdayThursdayFridaySaturda y"
editX2: wtf? why cant i get rid of the space, oh well, anyway, there should be no space before sunday
Code:#include <stdio.h>
const char *daydata =
"SundayMondayTuesdayWednesdayThursdayFridaySaturday";
int daylengths[7] = {6, 6, 7, 9, 8, 6, 8};
void dayname (int day, char *p)
{
int offs, i;
for (offs = 0, i = 0; i < day; offs += daylengths[i++]);
(void) memcpy (p, daydata + offs, daylengths[i]);
*(p + *(daylengths + i)) = '\0';
}
int main (void)
{
int j = 0;
char buff[20];
for (j = 0; j < 7; j++)
{
dayname (j, buff);
(void) printf ("%s\n", buff);
}
return printf ("Done!\n");
}
wow.. talk about lazy...
orCode:void displayDay(int);
void displayDay(int Input)
{
switch(input)
{
case 0: cout << "Monday";
break;
case 1: cout << "Tuesday";
break;
}
return ;
}
orCode:void displayDay(int);
void displayDay(int Input)
{
if (Input == 0)
cout << "Monday";
else if (Input == 1)
cout << "Tuesday";
return ;
}
Code:enum Days{Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday}
Days Input;
Input = Monday; // Input = Monday; or Input = 0;
Input = Days(4); // Input = Friday; or Input = 4;