Ok, I'm not too sure if this would be considered a matrix, but what I'm trying to do promts the user for 2 characters, and one integer.

For example, say you key in * G 3

the cout would be...

*G*
G*G
*G*

If you keyed in % \$ 5

%\$%\$%
\$%\$%\$
%\$%\$%
\$%\$%\$
%\$%\$%

I've tried various scenarios of code, and havent had much progress. I have however worked out what I *think* is the correct formula for odd integer inputs, and evens.

for example, if the entries are 0 * 6, where n = 6, then my multiplier formula would be ((n/2)-1).
so, it would result in:

0 and *, being multiplied by (6/2)-1, which is 2, resulting in the correct... 0*0*0* (eg. the initial output with another 2)

and if it is an odd number, ((n-1)/2)-1

Now, my problem is... how do I get the program to know its Odd numbers or even numbers...? and where do I insert my formula?

Second... how do I solve the multiple rows issue? I know how to get the columns (with my formulas).

I'm fairly new to C++, and I've done these so far... but I stopped when I realised it would be neverending... any ideas? :-/

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

int main ()
{
char x, y;
int n;

cout << "Enter two characters and an integer: ";

cin >> x >> y >> n;

if (n == 1)

cout << x;

else if (n == 2)

cout << xy;
cout << yx;

return 0;

}``````

send to me coding for booth algorithm of 8bit multiplication fastly

send to me coding for booth algorithm of 8bit multiplication fastly

appreciate the help, but what is a "booth algorithm of 8bit multiplication"?

First off rayone is just random troll.

Second: Your problem is that you have (a) forgotten to put a endl
after the output and (b) forgotten that x and y are separate entities.
So you need

``cout<<x<<y<<endl;``

finally you forgot that after an if you need { }, so that the braces enclose everything that you want to do: You don't need { } BUT you can put it, if you have ONE statement. If you are unsure USE { }

This is your code in a working format. Note it only works for n=1 or n=2. You can with a loop make it general.

I have done one other thing. I have fixed x,y,n in the program. This is good practice. Your test program will now be quick to change/compile/run. You will not be slowed down by entering lots of values each time. When it works, compile for a different number or two, then when that works, deal with keyboard/user input.
This will speed up your development process.

``````// includes here...
int main()
{
char x('a');
char y('b')
int n(2);

if (n == 1)
std::cout<<x<<std::endl;
else if (n==2)
{
std::cout << x<<y<<std::end;
std::cout<<y<<x<<std::endl;
}
return 0;
}``````
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.