Thread: C++ Programming

  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2006
    Rep Power

    C++ Programming

    // Ex11.cpp, Multiple alternatives
    // This is getting a bit labourious! We will see an easier way to do this later
    // c:\Borlandc\work\Ex11.cpp
    #include <iostream.h>
    void main(void)
     char day; // gives us a bit more practice with 'char' variables
     cout << "enter the first letter of the day\n";
     cin >> day;
     if	(day == 'm' || day == 'M' )cout << "Monday";
     else if (day == 't') cout << "Tuesday";
     else if (day == 'w' || day == 'W') cout << "Wednesday";
     else if (day == 'T') cout << "Thursday";
     else if (day == 'f' || day == 'F') cout << "Friday";
     else if (day == 's') cout << "Saturday";
     else if (day == 'S') cout << "Sunday";
     } // end of main
    // trying to get days tues, thurs, saturday, sunday to output in Lower and upper case. Don't know how to do this.

    Comments on this post

    • Andrew80 disagrees : do your own homework
    Last edited by SimonGreenhill; October 8th, 2006 at 09:53 PM. Reason: adding code tags
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 2006
    Rep Power
    Since someone is going to point this out eventually, might as well be me:

    1. Why is this not posted in the C++ programming forum?
    2. Your thread title is horrible. You could post this in the C++ programming forum, and then put the essence of your question in the title.
    3. Your code should be posted in CODE tags. This preserves indentation in the code. And makes it look nice.

    Now then, onto the real point of your question. Actually, your question is a bit vague. What is the end result you want? You want "Tuesday" and so on to output in lowercase. Why don't you just manually output them as wanted?

    Two more things to note. First, as per C++ standard, main returns an int. So it is int main, not void main. Second, it's #include <iostream>. Not iostream.h. As per the 99 revision, the standard library has been moved in the std namespace. Hence, you most likely will want to add using namespace std to your code.

    Comments on this post

    • Zoso agrees : Right ! I'd like to see people refer to the Holy C++ Standard more often !
  4. #3
  5. (retired)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2003
    The Laboratory
    Rep Power
    Thread moved to the C programming forum.

    Also note that we won't do your homework for you.


IMN logo majestic logo threadwatch logo seochat tools logo