Hello all I am new to this community have found help on it without even joining however I cannot find a solution to my specific problem...

Write a program that reads five numbers (each between 1 and 30).
For each number read, your program should print a line containing that many number of adjacent asterisks.

I know how to write an asterisk program i just do not understand how to implement it into these specifications. You see even though this is a basic course I always take a step back and write even simpler programs first before going onto harder more complex problems in the text book. it really helps me understand the basics of C++ any help is welcomed!

Show us what you did so far then we will be glad to make corrections and suggestions.
As a preview, I think you will want to use a for loop nested in a while loop. We'll get into the specifics when you post your code.

As stated before i make simple programs first and then edit them for my workbook problems i have made a code to display 1-9 in asterisk form but how to i get it to implement to the other specifications.

#include <iostream>

using std::cout;
using std::endl;

int main()
{
//declare variables
  const char aster = '*';
  int a = 9;
  int x = 0;
  //while loop
    while (a > 0)
    {
        x = a;
      while (x > 0)
     {
        cout << aster;
        x = x - 1;
     }
        a = a - 1;
     cout << endl;
    }
//end while


    return 0;
}   //end of main function

Ok, your original post says you want to read in 5 numbers so you'll want to use this as the condition in the while loop:

int x=1;
while(x<6)
{
//prompt to enter number
//accept user input

Next you'll want to use a for loop to actually display the asterisks

for(int i=1; i<=num; i++)
    {
            cout<<'*';
    }        
    cout<<endl;

Finally you want to increment the value of x and close the while loop.
Try to understand that and let me know if you have any questions.

**EDIT**
You will also need to include an error check to make sure the values are between 1 and 30. Use an if statement.

Thanks for the advice; So i put part A code in front and Part B code last or is there specific area i need to implement the codes in order to make them work.

Do you think you can show me a completed copy of the code source that would help me visualize it better.

Do you think you can show me a completed copy of the code source that would help me visualize it better.

LOL, nice try. "Help me visualize it better"--That's a new one. ;)
You need to follow exactly what I said in my previous post.
Start your while loop.
Ask for and accept user input.
Begin for loop to print the number of asterisks. The number of asterisks will be as many as the number entered by the user.
Close for loop
Increment x by 1 using x++
Close while loop

So in essence, the for loop will be enclosed in the while loop.

Thats it. Give it another shot, you'll get it.

Sorry about that lol. and sorry if this seems basic but how do i ask the user to input the number from 1-30 but it can only be a number from 1-5

Sorry about that lol. and sorry if this seems basic but how do i ask the user to input the number from 1-30 but it can only be a number from 1-5

The while loop makes the process repeat 5 times.
To ask the user to enter a number use:

cout<<"enter a number between 1 and 30 inclusive"<<endl;

To accept the input use

cin>>number;

Obviously number must be declared as an int value. This same variable will be used in the for loop, so make sure they are the same. You'll also want to use an if statement to make sure the number input is actually between 1 and 30.

Also include this line before int main()

using namespace std;

I'm not sure if that was in your original code.

ok thanks a lot for all your help I get it now. In my class the teacher just lectures and we don't program at all that is for hw!!!!

ok thanks a lot for all your help I get it now. In my class the teacher just lectures and we don't program at all that is for hw!!!!

Glad I can be of help.
If you have no further questions please mark the thread solved.
If you have more questions, ask. :)
Thanks.

for(a=1;a<=100;a++)
{
cout<<"\n*";
}

This is a simple for loop statement with the output of asterisk. :)

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.