Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8879787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:01:46+00:00 2026-06-14T20:01:46+00:00

I can’t seem to get it to count down on the last verse. I’ve

  • 0

I can’t seem to get it to count down on the last verse. I’ve tried to create a new variable that subtracts 1 and put that variable in the last verse and it works for all but numbers 9, 19, 29, 39…99. Can someone please give me a hint or point me in the right direction? I’ve also tried creating another loop to count down and read it from the array. I have only been learning this for a few months and don’t know what else to try. I thought I once I got to this point the hard part was behind me, not so much, for me at least. Thank you. It is c++ in Visual studio 2010.

#include <iostream>
#include <string>
using namespace std;

string tens[11] = {""," Ten"," Twenty"," Thirty"," Forty"," Fifty"," Sixty"," Seventy"," Eighty"," Ninety"};
string ones[10] = {"","-One","-Two","-Three","-Four","-Five","-Six","-Seven","-Eight","-Nine"};
string s_ones[11] = {" Zero"," One"," Two"," Three"," Four"," Five"," Six"," Seven"," Eight"," Nine"};
string other[ ] = {" Ten"," Eleven"," Twelve"," Thirteen"," Fourteen"," Fifteen"," Sixteen"," Seventeen"," Eighteen"," Nineteen",""};


int main()
{
    for(int i = 99; i >= 0; --i)
    {
        int tens_place = i / 10, ones_place = i % 10, small_ones_place = i % 10;


        if(10 <= i && i < 20)
        {
            cout << other[i - 10] << " bottles of beer on the wall. \n"
                 << other[i - 10] << " bottles of beer.\n"
                 << " Take one down, pass it around,\n"
                 << other[(i - 10)] << " bottles of beer on the wall.\n\n";
        }
        if(20 <= i && i <= 99)

            cout << tens[tens_place] + ones[ones_place] << " bottles of beer on the wall. \n"
                 << tens[tens_place] + ones[ones_place] << " bottles of beer.\n"
                 << " Take one down, pass it around,\n"
                 << tens[tens_place] + ones[ones_place] << " bottles of beer on the wall.\n\n";

        if(2 <= i && i < 10)

            cout << s_ones[small_ones_place] << " bottles of beer on the wall.\n"
                 << s_ones[small_ones_place] << " bottles of beer.\n"
                 << " Take one down, pass it around,\n"
                 << s_ones[small_ones_place] << " bottles of beer on the wall.\n\n";

        if(i == 1)

            cout << s_ones[small_ones_place] << " bottle of beer on the wall.\n"
                 << s_ones[small_ones_place] << " bottle of beer.\n"
                 << " Take one down, pass it around,\n"
                 << s_ones[small_ones_place] << " bottles of beer on the wall.\n\n";

        if(i == 0)

            cout << s_ones[small_ones_place] << " bottles of beer on the wall.\n"
                 << s_ones[small_ones_place] << " bottles of beer.\n"
                 << " Go to the store and get some more,\n"
                 << " Ninety-nine bottles of beer on the wall.\n\n";

        }
return(0);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T20:01:47+00:00Added an answer on June 14, 2026 at 8:01 pm

    It comes very close to working correctly. All you have to do is subtract 1 from the one’s place index on the last line. Like this:

    << " Take one down, pass it around,\n"
    << other[(i - 10)-1] << " bottles of beer on the wall.\n\n";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can't seem to get this to work. The idea is to calculate the percentage
Can I change the field public virtual ClassOne ClassOne { get; set; } to
Can any one tell, how to get the result of LINQ query contains group
Can someone thoroughly explain the last line of the following code: def myMethod(self): #
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Can I call select before recv_from on a socket that is blocking?
Can I have a project that has some parts written in c and other
Can some one confirm me that only one UIWindow instance is possible in any
Can we change the color of the divider? Apple documentations says, that we can
Can someone please explain why this doesn't work? MyClass myClass1 = new MyClass(); object

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.