Question

In: Computer Science

A simple repetitive song with varying verse, "The Ants Go Marching" provides a simple assignment for...

A simple repetitive song with varying verse, "The Ants Go Marching" provides a simple assignment for remembering the basic Control Structures - loops, switch statements, if-then-else statements, etc., that you learned in programming fundamentals, and which are very similar in C++. Write a c++ incremental program counting from one by one to 10 by ten with these lyrics

The ants go marching one by one, hurrah, hurrah The ants go marching one by one, hurrah, hurrah The ants go marching one by one, The little one stops to suck her thumb And they all go marching down to the ground To get out of the rain, BOOM! BOOM! BOOM!

The ants go marching two by two, hurrah, hurrah The ants go marching two by two, hurrah, hurrah The ants go marching two by two, The little one stops to tie her shoe And they all go marching down to the ground To get out of the rain, BOOM! BOOM! BOOM!

Solutions

Expert Solution

Hi Friend, Please find my implementation.

Please let me knwo in case of any issue.

#include <iostream>
using namespace std;

int main(){

   for(int i=1; i<=10; i++){

       for(int j=1; j<=3; j++){

           cout<<"The ants go marching ";

           switch(i){
               case 1:
                   cout<<"one-by-one";
                   break;
               case 2:
                   cout<<"two-by-two";
                   break;
               case 3:
                   cout<<"three-by-three";
                   break;
               case 4:
                   cout<<"four-by-four";
                   break;
               case 5:
                   cout<<"five-by-five";
                   break;
               case 6:
                   cout<<"six-by-six";
                   break;
               case 7:
                   cout<<"seven-by-seven";
                   break;
               case 8:
                   cout<<"eight-by-eight";
                   break;
               case 9:
                   cout<<"nine-by-nine";
                   break;
               case 10:
                   cout<<"ten-by-ten";
                   break;
           }

           if(j == 1)
               cout<<", hurrah, hurrah ";
           else if(j == 2)
               cout<<", hurrah, hurrah ";
           else
               cout<<", The little one stops to suck her thumb And they all go marching down to the"
                   <<"ground To get out of the rain, BOOM! BOOM! BOOM!"<<endl;
       }
       cout<<endl;
   }

   return 0;
}


Related Solutions

5.6.2.  Programming Challenge : Song with Parameters Here’s another song, The Ants Go Marching, that is very...
5.6.2.  Programming Challenge : Song with Parameters Here’s another song, The Ants Go Marching, that is very similar to the This Old Man song in its repetitive structure. The ants go marching one by one, hurrah, hurrah The ants go marching one by one, hurrah, hurrah The ants go marching one by one The little one stops to suck his thumb And they all go marching down to the ground The ants go marching two by two, hurrah, hurrah The ants...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT