Premium Essay

Principle of Programming Languauges

In: Computers and Technology

Submitted By rajausama321
Words 344
Pages 2
Q1. Decide which of the following identifier forms is most readable, and then support that decision. SumOfSales sum_of_sales SUMOFSALES

Ans: The identifier “sum_of_sales” is most readable because it is clearly identify the meaning of the variable. The underscore will separate the word which clearly define the meaning that this variable is used to store the sum vales of the sales. That’s why we will decide this identifier.

Q2. Some of the programming languages are type less. What are the advantages and disadvantages of having no types in a language?
Ans: Type less languages are those languages in which we don’t need to specify the type of the variables used in a program. The compiler implicitly take the type of the variable according to the value assigned to it.

Advantages: * We don’t need to specify the type of variable which reduce the limitation for assigning the values. * Type less languages allow to perform the different operations, because it implicitly convert the types of variable.
Disadvantages:
* Sometimes we don’t want to take the variables types dynamically, we have to specify the type explicitly for our required operation * It is difficult to guess the types of variable in type less language, because it depends on the type of the value assigned to it.
Q3. Consider the following Pascal program skeleton Program main var x, y, z : integer Procedure sub1; var a, y, z : integer procedure sub2; var a, b, z : integer; end; end; procedure sub3 var a, x, w : integer; end;
List all of the variables along with the program units where they are declared, that are visible in the bodies of sub1, sub2 and sub3, assuming static scoping.
Ans: In sub1: The variables a, y, z and x of main, are visible to it because the x is in its parent procedure. In sub2: The variables a, b, z, and y of

Similar Documents