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 9296281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T21:47:55+00:00 2026-06-18T21:47:55+00:00

I was wanting to get some tips on how to get my program to

  • 0

I was wanting to get some tips on how to get my program to output a desired number of columns by the user. For example, if the user enters 2 for termsPerLine, then the program should print the values generated by the Juggler series in two columns, or if the user enters 3 for termsPerLine, 3 columns and so forth. The output variable is firstTerm. Any assistance would be great.

#include <string>
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int ValidateInput(string Prompt);

int main()
{
    int count;
    double Odd;
    double Even;
    long long int firstTerm;
    int noOfTerms;
    int termsPerLine;

    cout << "Program will determine the terms in a Juggler Series" << endl << endl;

    firstTerm = ValidateInput("Enter the first term: ");

    noOfTerms = ValidateInput("Enter the number of terms to calculate (after first): ");

    termsPerLine = ValidateInput("Enter the terms to display per line: ");

    cout << "First " << noOfTerms << " terms of JUGGLER SERIES starting with " << firstTerm << endl;

    count = 1;

    do
    {
        if (firstTerm % 2 == 0 )
        {
            firstTerm = pow(firstTerm , 0.5);
            cout << setw(16) << firstTerm << endl;
            count++;
        }
        if (firstTerm % 2 != 0 )
        {
            firstTerm = pow(firstTerm, 1.5);
            cout << setw(16) << firstTerm << endl;
            count++;
        }
    }
    while (count <= noOfTerms);

    cout << endl;
    system("Pause");
    return 0;
}


int ValidateInput( string Prompt)
{
    int num;
    cout << Prompt << endl;
    cin >> num;

    while ( num <= 0 )
    {      
        cout << "Enter a positive number" << endl;
        cin >> num;
    } 

    return num;  
}
  • 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-18T21:47:56+00:00Added an answer on June 18, 2026 at 9:47 pm

    Try this at the top of the loop:

    if ((count % termsPerLine) == 0)
    {
        cout << "\n";
    }
    

    or this at the bottom of the loop:

    if ((count % termsPerLine) == termsPerLine)
    {
        cout << "\n";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm wanting to run AJAX to get some URL data, build an object from
I'm wanting to get a WCF-over-TCP service working. I was having some problems with
I am using a $.get request to get some data and am then storing
In wanting to get some hands-on experience of good OO design I've decided to
Lately I've been wanting to get into assembly coding, just to have some experience
I have been wanting to get a thumbnail of websites for quite some time
I'm wanting to get some binding working in my mvc application. I find nested
I'm wanting to get the filepath ie /sites/default/files/myfile.pdf for my file uploads. I'm using
My table named pictures has a column named pic and I'm wanting to get
I'm wanting to extract a zip file loaded with images into memory in some

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.