How can I declare N in c++ like this? 1<N<10^6 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How can I declare N in c++ like this? 1<N<10^6

I realy need your helps...

15th Nov 2019, 9:13 AM
.Moony.
6 Answers
0
This is a very naive thinking but if you really want the number to be in range before further process then you can do something like this. #include <stdio.h> #include <math.h> int main() { unsigned long int a; scanf("%ld",&a); if((a>=1) && (a<=pow(10,6))){ printf("The number is in range"); //put your code inside } else{ printf("The number is not in range"); } return 0; }
15th Nov 2019, 10:37 AM
Avinesh
Avinesh - avatar
+ 4
You can use constants to define the upper and lower limits and use if statements for checking like what Avinesh did.
16th Nov 2019, 9:52 PM
Sonic
Sonic - avatar
+ 1
Are you missing an equal to symbol? 1<=N<=10^6
15th Nov 2019, 10:22 AM
Avinesh
Avinesh - avatar
0
Did you mean to declare, or to check whether <N> meets the constraint `1 < N < 10 ^ 6` ?
15th Nov 2019, 9:33 AM
Ipang
0
I saw a question in university, about to declare N, that N is greater than 1 and less than 10^6 Anr I have no idea how to declare it .
15th Nov 2019, 9:42 AM
.Moony.
0
Yes sth like that
15th Nov 2019, 10:23 AM
.Moony.