Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In Ada, declarations of named constants have the option of omitting the type of

ID: 3805675 • Letter: I

Question

In Ada, declarations of named constants have the option of omitting the type of the constant, as illustrated by the following examples: N: constant Integer:= 100;- -Type of constant is specified N: constant:= 100; - -Type of constant is omitted (a) Are both kinds of declarations allowed for all constants, or are there any cases where only one kind is allowed? (b) What differences are there, if any, in what expressions are allowed as the value of a constant? (c) What differences are there, if any, in how the constants can be used?

Explanation / Answer

a) Yes, oth kinds of declarations are allowed for constants. Constant is a variable whom value once assigned can never be changed during execution of a program where it is defined. Now, first one has explicitly defined the type of data being stored ie only integer values can be stored for first case whereas in second case its a generic named constant where any value can be stored.

b) the difference between both type of declaration is that first named constant can have only integer value and if any other value is provided it will show error whereas on the other hand for second declaration as no type is provided we can store any value in the constant variable.

c) there are no differences on the way to use as both are having integer values only stored.