C Programming, how to maintain constraint while taking input

HOw do we maintain the constraints in problems give.
Eg 1<=t<=100
so here I can maintain the constraint of t<100 by using %2d but it is asked to maintain the constraint of t<=100, so how do i do that.
similarly,
how do we maint the constraint of n<=1000000000.

Hey @shivam_sarda

you don’t have to maintain the constraint, just take the input for the first test case and print them(same for other cases also). Though you can also save it in the array and output them at last after computing answers for all the test cases.

let’s suppose you have the question of finding factorial for ‘t’ testcases, where each test case has one number as input.

input:

3 // no. of testcase

3

4

5

output:

6

24

120

See this code for an explanation C++.

The constraints does not mean that you have to MAKE them.

The constraints are more like, the problem setting telling you that “The test cases evaluating your program will have numbers in this range”.

If numbers are small, brute force works, else a optimized solution is required. It is to give a rough idea to participant about the input, so he is able to decide the apt approach, data-types etc.

//