Here is what I have so far:

#include <iostream>


using namespace std;


int main()
{

    int i;

    for (i = 1; i <= 12; i++)
    {
        cout << i << endl;
    }
    if (i = 4)
        cout << "My lovely month in which I've been born! \n";









    system("pause");
    return 0;
}

I honestly don't have any idea how to do this... If someone would please help me it would be appreciated :(

Recommended Answers

All 5 Replies

int main()
{
    int i;
    for (i = 1; i <= 12; i++)
    {
        cout << i <<;
        if (i == 4) {
        cout << " My lovely month in which I've been born! \n";
        }
        else{
        cout << endl;
        }
    }

What are you trying to do ..?
I think what you want to do is place the if statement inside the for loop ..

Oh thank you very much!
So it had to be inside the loop itself...

Yes, and = is assignment operator while == is comparison.

I recomend you to use switch...case clause:

for(int i=1; i<=12; i++)
{
   cout << i << ' ',
   switch(i)
   {
     case 1: cout << "My first message\n"; break;
     case 2: cout << "My second\n"; break;
     //...
   }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.