0

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 :(

Edited by Florin_1: spelling

4
Contributors
5
Replies
17
Views
2 Years
Discussion Span
Last Post by Maritimo
0
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;
        }
    }

Edited by Suzie999

0

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

0

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

-1

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;
     //...
   }
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.