C++ problem | Sololearn: Learn to code for FREE!

+1

C++ problem

How can I make a limitation for a variable I want to declare that for example 100< i=<1000

4/12/2021 5:17:12 PM

Sahaarr

15 Answers

New Answer

+2

Not sure what do you mean, but this is what I did: https://code.sololearn.com/cZZnKQ7abQ9U/?ref=app

+1

Coder Kitten Thank you!

+1

Maher Al Dayekh Thank you for answering!๐Ÿ™๐Ÿผ

+1

In addition, if you care about your memory usage, you can use bitfields, which are explained here: https://en.cppreference.com/w/cpp/language/bit_field What's more, if you are sure about limits, and you're sure it will never be negative, you can use unsigned type. You can also learn about data structure alignment (e.g memory padding and packing). At least if you want to know something more about how memory works

+1

https://code.sololearn.com/cIPBZyDUlF72/?ref=app Use the above code ro get greater than 100 lesser than 1000 Simple code friend

+1

For limitation use this code https://code.sololearn.com/coxQMtmUxdpH/?ref=app

+1

In an if-statement? https://code.sololearn.com/cDKOUNe2sYyU/?ref=app

0

Coder Kitten I want to define i as variable that ranges from 100 to 1000 Should I use cmath or other libraries?

0

Sahaarr is the code available for you, or something is wrong?

0

Maher Al Dayekh I'm actually solving a question, At first I used i in main function in a "for" Then I wanted to use it again in another function, but I don't know how to define i's limitation in that function :(

0

#include <iostream> using namespace std; int main() { int crabs; int Trio; cin >> crabs; Trio = crabs/3; cout << Trio; return 0; }

0

#include<iostream> using namsspace std; Int main() { int crabs; int trio; cim >> crabs; Trio = crabs/3; cout << Trio; return 0; } Average word :- https://www.sololearn.com/discuss/2875277/?ref=app