Need some help with my C++ practice

Hi all, i am learning C++ and have some test mockup available with me while practice, i was able to solve 20+ answers but i got stuck up with some of these:

can anyone help me please?

1
2
3
4
5
6
7
8
9
10
11
1. Define a variable named Marks to represent a small strictly positive integer value and assign it a value of 89. 

2. Define a variable named Salary to represent a large strictly positive integer value and assign it a value of 3,000,000.

3. Write a single C++ statement to assign the smallest value that can be represented by an integer variable.

4. Write a single C++ statement to assign the largest value that can be represented by a strictly positive, but small integer (ยก255) variable.

5. Write a single C++ statement to assign the largest value that can be represented by a single-precision floating-point variable.

6. Write a single C++ statement to output the largest value that can be assigned to a double-precision floating-point variable.


Please help me with these.. Thanks :)
1, 2 and 4 appear to be trick questions.
There is no built-in integer type that can represent a "strictly positive integer value".

If these questions were set buy a career teacher, there is a distinct possibility that "strictly positive" is being confused with "non-negative".

There is also delicious ambiguity in the terms "small" and "large".

1. Define a variable named Marks to represent a small strictly positive integer value and assign it a value of 89.
1
2
unsigned char Marks ; // use unsigned char for a non-negative value with limited range 
Marks = 89 ;

Perhaps, this is what the career teacher expects; though there is no assignment here:
unsigned int Marks = 89 ;

Likewise for 2, use unsigned long long for a non-negative value with large range

For smallest value that can be represented by an integer etc, see std::numeric_limits<>
http://en.cppreference.com/w/cpp/types/numeric_limits
For example, the smallest value that can be represented by int is std::numeric_limits<int>::min()
and the largest finite value that can be represented by double is std::numeric_limits<double>::max()



Topic archived. No new replies allowed.