Is there a way to enter a number through another number? [closed] - c++

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I'm taking a C++ class in school, (No experience with programming) so I realize that this is a very dumb question and also horribly worded but here it is:
Is there any way to enter 6-21 (As in 6 through 21) into a boolean expression? I've tried it like this:
if (regs = 6-21)
But it assumes that I'm trying to subtract. What I'm trying to ask is, is there a way to enter a number through another number? Is it even possible?

Here is how you do it:
if (regs >= 6 && regs <= 21) {
// some code
}
>= means "greater than or equal to".
<= means "less than or equal to".
&& means "and", as in "if this AND this is true".

Related

How do i take fifth power of a number in c [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I am creating a gp calculator in c++ ,But in gp the formulae has common ratio to the power of the term number. in order to get calculate that term i need to know how do i take the number as power for some other number, is there any operator for doing this.
If both arguments are floating point numbers, you have to use formula xᵐ = exp(m log x).
Supposedly std::pow does that for you. If your program requires to match some particular test patterns, further investigation may be required.
Know your <math>
As long as x != 0 to get any power:
exp(log(x)*power)
The interesting tidbit here is that if power is 1.0/y it will extract the y-root of the value.

How to find the maximum number formed with the digits of a given number WITHOUT ARRAYS [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I'm really wondering how to solve this problem without using arrays. I have been literally scratching my head for hours without success. Help is highly appreciated!
Let me show you how to achieve this with the number 12365:
12365 (largest digit : 6)
62315 (largest remaining digit : 5)
65312 (largest remaining digit : 3)
65312 (largets remaining digit : 2)
65321
The calculations can be performed, using simple MOD() calculations.

Who can explain this code ? Why it shows 1 [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
How does this work?
int a=5<=5;
cout<<a; // output : 1
Who can explain why output is 1?
That's because
<= has higher priority than = so it is calculated first.
5 <= 5 returns a boolean, which is true.
It is converted into an integer, which is 1.
then 1 is assigned to a.
so a equals 1 now.
5<=5 is true which, when converted to an integer is 1.
You assign this value to a which then holds the value 1. Which you then output.
You may want to read https://en.cppreference.com/w/cpp/language/operator_precedence

C++ input value process as math function [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I’m very new in C++ and I need your help. I want to use the input value as a mathematical function then print the result.
What i need is:
When user input: 2 +1 and hit Enter then output (cout>>)
should be your result is: 3 (the sum of 2 + 1)
The mathematical symbol could be + or * or / or -.
Could you please help me with some example?
Thanks in advance!
Search for "Reverse Polish notation" and implementation in C++

2D Arrays - Creating virtual Creatures? (C++) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Next, this is where it gets confusing. I have to create a virtual creature by storing a letter into a random position in the array (the array can be up to 20x20 in size). How would I go about doing that?
Nevermind, figured it out
While I don't intend to provide the answer to homework, here are some commands and concepts that should help you:
cin - to read input from the user
rand() % number - (see http://www.cplusplus.com/reference/cstdlib/rand/ for an example) to generate random numbers
You will probably want to make your array of type "char" instead of "int"
Here is a link to functions in C++ - http://www.cplusplus.com/doc/tutorial/functions/
Here is a link to operators in C++ (specifically you will want to use ==) - http://www.cplusplus.com/doc/tutorial/operators/
For example, to see if x is equal to y:
if(x == y)
{
cout << "x equals y!";
}