In Ada 95 an integer variable may be declared to be Integer

In Ada 95, an integer variable may be declared to be Integer, Natural, or positive (among other choices). Which. of these are types and which are subtypes? What is the difference between: integer. Natural, and Positive (other than the fact mentioned in part (a))?Can an Integer value be assigned (o a Positive variable? If so, what happens if the value is outside the range of Positive? (Be specific.)

Solution

Answer :

an integer variable may be declared to be Integer,Natural,or Positive .

a)Which of these are types and which are subtypes?

Answer :

Integer is type.     (Base type is Number)

Natural,Positive are subtypes.

b)What are the differences between Integer,Natural,and Positive?

Answer :

1.Integer datatype to store signed integers.

2.A subtype associates a base type with a constraint,it contains subset of values.

3.Natural and Positive keep assigning of nulls to an integer variable.

4.Integer values requires less storage and number values.

.................

c)Can an Integer value be assigned to a Positive variable?If so,what happens if the value is outside the range of Positive?

Answer :

Yes,We can an Interger value be assigned to a Positive .

If so,Overflow occurs,bits are lost because variable not allocated enough memory.

 In Ada 95, an integer variable may be declared to be Integer, Natural, or positive (among other choices). Which. of these are types and which are subtypes? Wha

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site