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

Programming

...Calling an external function or program that is written in a different programming language like a Java program within a Visual Basic program you first need to know the Function fundamentals that’s executed in any programming language. I came across this website called maples, where they have the ability to connect to and call functions from other programming languages. Maple uses this for various reasons. Like all other languages, the F# function has a name, it can have parameters, has a body and takes arguments. F# also supports functional programming constructs such as handling functions as values, depleting unnamed functions in expressions, composition of functions to form new functions, curried functions, and the implicit definition of functions by way of the partial application of function arguments. Maple's help system documents all the External Calling functions so you can see what is available. Briefly, however there are functions for converting Maple types to C and back, creating and interacting with Maple data structures creating and interacting with Maple language elements (names, procedures, etc), printing to the Maple interface, memory allocation, evaluating Maple statements and raising exceptions. There is even a C interface to the Task Programming Model. The function-name is an identifier that represents the function. The parameter-list consists of successive parameters that are separated by spaces. You can specify an explicit type for each parameter, as......

Words: 394 - Pages: 2

Programming

...times 4 and stores the result in a c. Divides a by 3.14 and stores the result in b d. Subtracts 8 from b and stores the result in a 8. Write a pseudocode statement that assigns the sum of 10 and 14 to the variable total. 9. Write a pseudocode statement that subtracts the variable downPayment from the variable total and assigns the result to the variable due. 11. If the following pseudocode were an actual program, what would it display? Declare Integer a = 5 Declare Integer b = 2 Declare Integer c = 3 Declare Integer result Set result = a + b * c Display result 12. If the following pseudocode were an actual program, what would it display? Declare Integer num = 99 Set num = 5 Display num PROGRAMMING EXERCISES (Input, processing, and output) 2. Sales Prediction A company has determined that its annual profit is typically 23 percent of total sales. Design a program that asks the user to enter the projected amount of total sales, and then displays the profit that will be made from that amount. Hint: Use the value 0.23 to represent 23 percent 3. Land Calculation One acre of land is equivalent to 43,560 square feet. Design a program that asks the user to enter the total square feet in a tract of land and calculates the number of acres in the tract. Hint: Divide the amount entered by 43,560 to get the number of acres. 4. Total Purchase A customer is a store is purchasing five items. Design a program that asks......

Words: 1054 - Pages: 5

Programming

...the module in which its declared and only statements inside that module can access that module can access the variable. 5. The local variable usually beings at the variables declaration and ends at the end of the module which is then the variable is declared. 6. The difference between the both is that only a copy of the arguments value is passed and passing by reference means that the argument is passed into a specific type of parameter. 7. Global variables make debugging difficult because they make programming hard to understand, modules that use global variables are usually dependent and you have to track down every statement. Algorithm Workbench 1. Module main() Declare userNum as Integer Display “Enter a number” Input userNum Call TimesTen(usernum) Display usernum End 5. 13.4 00.0 00.0 6. 1, 3.4 0, 0 0, 0 7. Allows changes the values of passed parameters 1,3.4 0,0 0,0 Doesn’t allow changing of parameters 1,3.4 0,0 1,3.4 Programming Exercises 1. Kilo=input (“Enter distance in kilometers”) Miles=Kilo Print”, Kilo 2. Module TotalPurchase Declare Double amount, total Declare TAX=.06 While I<6 Display “Enter the price” Input amount Total=total+amount I=I+1 End while Display “Subtotal is:” + total Display “Tax is:” + (total*TAX) Display “Total is:”=(total*TAX)+total) End Module...

Words: 309 - Pages: 2

Programming

...Definitions ........................................................................................16 Datafile ............................................................................................................16 Record ..............................................................................................................16 Field ..................................................................................................................16 Key....................................................................................................................16 Search Key........................................................................................................17 A Quick Introduction to Object-Oriented Programming ......................................18 Problems with Procedural Languages ..............................................................18 Objects in a Nutshell ........................................................................................19 A Runnable Object-Oriented Program ............................................................21 Inheritance and Polymorphism ........................................................................24 New C++ Features ................................................................................................25 The string Class..............................................................................................25 The vector......

Words: 10065 - Pages: 41

Programming Languauges

...Introduction to Programming PT-104 | UNIT 1ASSIGNMENT | Research Popular Programming Languages | Associated with the Past Present and Future of Virtualization | | 9/30/2013 | Introduction to Programming 23 September 2013 Unit 1 Assignment 1 Exploring Programming Languages Platform virtualization vs. application virtualization Virtual machines (VMs), in their first incarnation, were created by IBM 60 years ago as a way to share large and expensive mainframe systems. And although the concept is still applied in current IBM systems, the popular concept of a VM has broadened and been applied to a number of areas outside of virtualization. Virtual machine origins The first operating system to support full virtualization for VMs was the Conversational Monitor System (CMS). CMS supported both full virtualization and paravirtualization. In the early 1970s, IBM introduced the VM family of systems, which ran multiple single-user operating systems on top of their VM Control Program—an early type-1 hypervisor. The area of virtualization that IBM popularized in the 1960s is known asplatform (or system) virtualization. In this form of virtualization, the underlying hardware platform is virtualized to share it with a number of different operating systems and users. Another application of the VM is to provide the property of machine independence. This form, called application (or process) virtualization, creates an abstracted environment (for an application),......

Words: 1974 - Pages: 8

Programming

...- -[ ] http://blog.renren.com/blog/73603/740437492 » / [ ] 2011-07-18 10:47 | ( : ) http://coolshell.cn/articles/4990.html 6 12 programming An open letter to those who want to start id Mailper Python Web “ Build Your Programming Technical Skills “ ( ) Notes/ActiveX/COM/ADO/ATL/.NET …… Mailper Delphi/Power builder ” Lotus 5 3D TA 561 ” The architecture of w-ai.org –... Some updates and my first Engl... / 10 Unix/Linux Windows 1 Linux Web+ 1 Python/Ruby Web 2 iOS Android Windows Windows Windows Linux+ Windows 9 : csv ( log python csv, python open, python sys) 52 word count (sys, os, path) (python sqlite) print Google (phrase, domain, use reader to follow tech blogs) 2 ( Vim / Emacs / Notepad++ Source Insight ( ctag) Cool IDE) / / 3 Unix/Linux Shell windows man ls/chmod/chown/rm/find/ln/cat/mount/mkdir/tar/gzip … sed/awk/grep/tail/less/more … ps/top/lsof/netstat/kill/tcpdump/iptables/dd… /etc /var/log /proc linux vmware player Ubuntu 1 6 9/6/13 1:36 PM - -[ ] http://blog.renren.com/blog/73603/740437492 /Linux 4 Web Web HTML CSS HTML Firefox + Firebug Javascript HTML DOM Firefox + Firebug Apache PHP PHP PHP chrome Nginx HTML MySQL MySQL SQL http://www.stanford.edu/~ouster/cgi-bin/cs142-fall10/index.php ) javascript HTTP: The Definite Guide browsers) Cookie/Session jQuery 4 3-5 ExtJS + Ajax ( +JSON (proxy, gateway, Javascript box model chrome DOM......

Words: 807 - Pages: 4

Errors in Programming

...out of the ordinary happens from the main logic of a program. A second advantage of exceptions is the ability to propagate error reporting up the call stack of methods which allows grouping and differentiating error type objects. In traditional programming, error detection, reporting, and handling often leads to confusing code. This presents disadvantages because you lose compile time support, the calling method must take care is testing all possible return values, and the code blends leading to cluttering. These errors can only be corrected by fixing the program. The best programs of this type forestall errors if possible, recover from them when they occur without terminating the application, or (if all else fail) gracefully terminate an affected application and save the error information to a log file. Using the latest and greatest seems to have caught on with exception handling input or output as well as file opening and system timeouts. It wasn’t available in earlier languages but seems to have been embraced. Not only does it address users’ errors but also normal system errors can be addressed as well. In addition, the error messages can be understood by all. References Editorial Board. (2014). Principles of Programming. Words of Wisdom, LLC. Additional information from http://www.tutorialspoint.com/java/java_exceptions.htm...

Words: 401 - Pages: 2

Programming

...Question: Analyze, design, and document a simple program that utilizes a good design process and incorporates sequential, selection and repetitive programming statements as well as at least one function call and the use of at least one array. The specific problem you need to solve for the final project is: Design a program that will allow a user to Input a list of your family members along with their age and state where they reside. Determine and print the average age of your family and print the names of anyone who live in Texas. 2. What is the required output? What is the necessary input? How you will obtain the required output from the given input? Clearly describe variable names and definitions. Include all necessary formulas and example calculations. 3. Display pseudocode of your overall design including the Main module and the order of the module, subprogram and function calls. 4. Create a Hierarchy chart for the overall program in raptor 5. detailed pseudocode for each module, subprogram and function. 6. Add pseudocode comments with all major functionality and most minor functionality commented 7. Show test plan covering all major functionality and most minor functionality. Multiple Input and expected output provided for most modules. SOLUTION: Analysis: For this program, user will be asked for name, age and state of their family members, one by one, until the user decides to stop entering this information. To achieve the given task (printing average family......

Words: 919 - Pages: 4

Principles of Programming

...machine language and assembly language? Machine language is the computer programming language that can be used for direct programming of the machine whereas Assembly languages are used to create a program on computer and then assembler is user to convert the program into binary code of machine level code. 2. Why are there so many programming languages? Evolution: Computer science is a young discipline; we’re constantly finding better ways to do things. The late 1960s and early 1970s saw a revolution in “structured programming,” in which the go to-based control flow of languages like Fortran, Cobol, and Basic2 gave way to while loops, case statements, and similar higher-level constructs. .Special Purposes: Many languages were designed for a specific problem domain. The various Lisp dialects are good for manipulating symbolic data and complex data structures. . C is good for low-level systems programming. Each of these languages can be used successfully for a wider range of tasks, but the emphasis is clearly on the specialty. Personal Preference: Different people like different things. Some people find it natural to think recursively; others prefer iteration. Some people like to work with pointers; others prefer the implicit dereferencing of Lisp, Clu, Java, and ML. The strength and variety of personal preference make it unlikely that anyone will ever develop a universally acceptable programming language. Expressive Power: One commonly hears arguments that......

Words: 917 - Pages: 4

Programming

...flowcharts to describe a program’s structure. Use pseudocode to define a program’s structure. Formulate solution algorithms for calculations by properly following the order of operations. Assignment Requirements Answer: * Short Answer 1, 2, 3, and 4 on page 71 * Algorithm Workbench Review Questions 1 and 2 on page 71 * Programming Exercises Questions 1 and 4, starting on page 72 Required Resources Textbook Submission Requirements Submit your written answers to your instructor at the beginning of Unit 3. Unit 2 Research Assignment 1: Researching Variable Naming Rules Learning Objectives and Outcomes Determine program input, processing, and output stages. Create the necessary flowcharts to describe a program’s structure. Use pseudocode to define a program’s structure. Formulate solution algorithms for calculations by properly following the order of operations. Assignment Requirements Use the Internet and the ITT Tech Virtual Library to research the following questions: What are the variable naming rules of Visual Basic, Python, and Java? List three similarities and differences in between the three programming languages. Required Resources Textbook ITT Tech Virtual Library: http://library.itt-tech.edu Submission Requirements Submit your written answers to your instructor at the beginning of Unit 3. Labs Unit 2 Lab 2.1: Pseudocode Learning Objectives and Outcomes * Use pseudocode to define a program’s structure. *......

Words: 450 - Pages: 2

Programming

...during the specific periods of learning. They can also be in a position to know the amount of fees unpaid and what they are expected to pay. The system can also be able to produce reports on the fees paid. It can be able to show the fee structure as well as the adjustments that are necessary. Some of the adjustment include fee reimbursements and scholarships that the student may be awarded. Some aspects of library information and attendance are also outlined in the system. The student can know the number of hours that he or she has spent in the library in a certain term. Human computer interactivity The system is supposed to have a great interaction with all the users. The system has been designed in accordance with user-centered principles. The school management system is consistent. Every functionality has been included properly so that the system meets all its objectives. In our case, any user cannot be able to use the system if the user is not authenticated. The operation is a way of ensuring that security is enhanced. Therefore, it becomes easier to use the system especially for new users. Inconsistent systems are hard to use and understand (Beyer, H., & Holtzblatt, K., 1997). . Mastering the art of using the system may take time. In our school management system, new users can use the system efficiently without experiencing a lot of problems. The system has a platform for giving out users’ feedback from the system. It can tell the user that he has done......

Words: 2413 - Pages: 10

Programming

...Programming 1 - Semester 1, 2015 Assignment 1 Release Date: 27 / 02 /2015 Total raw marks: 60 Assignment weight: 6% NOTE: This assignment is to be undertaken individually—no group work is permitted. Background information For this assignment you are to complete a partially completed menu-driven, Java console application, which allows the user to select one of four options:     Display Time and Date Swim Fitness Summary Calculator Sentence Analyser Exit The incomplete code solution (in the source file called MenuDrivenProgram.java) is in the same Assignment 1 folder, available via myRMIT. The partially completed program already has code to display the menu. You should study the code and then compile and execute it without implementing the following options. This will allow you to understand the flow of execution of the program, as is. a) Once the processing for the selected option has been completed the program should return to the menu (that is, the program should not terminate). b) You do not need to handle runtime errors of any kind for this assignment and you may assume that the user will always enter input in the correct format. This applies both to the menu itself and the processing of the menu options. Program Features Menu Option A - Display Time and Date (10 marks) The program should retrieve the current time and date from the system and then display it in the format shown......

Words: 1404 - Pages: 6

C Programming

...Welcome to CS 241 Systems Programming at Illinois Robin Kravets Copyright ©: University of Illinois CS 241 Staff 1 The Team  Robin Kravets    TAs   Office: 3114 SC rhk@illinois.edu Wade Fagen, Farhana Ashraf, Hilfi Alkaff and Mainak Ghosh Discussion Sections   8 sessions (Thursdays 9, 10, 11, 12, 1, 2, 3, 4) All sections in SC 0220 Copyright ©: University of Illinois CS 241 Staff 2 News and Email  Announcements and discussions: Piazza  http://www.piazza.com/illinois/cs241     All class questions This is your one-stop help-line! Will get answer < 24 hours e-mail   cs241help-fa12@cs.illinois.edu Personal questions not postable on the news group Copyright ©: University of Illinois CS 241 Staff 3 The Textbook  Introduction to Systems Concepts and Systems Programming      University of Illinois Custom Edition Copyright © 2007 Pearson Custom Publishing ISBN 0-536-48928-9 Taken from:    Operating Systems: Internals and Design Principles, Fifth Edition, by William Stallings UNIX™ Systems Programming: Communication, Concurrency, and Threads, by Kay A. Robbins and Steven Robbins Computer Systems: A Programmer's Perspective, by Randal E. Bryant and David R. O'Hallaron Copyright ©: University of Illinois CS 241 Staff 4 Your CS 241 “Mission”  Come to class     Read textbook    20% 7:00 – 9:00 PM October 15th Final  3% 47% Longer MPs are worth a little more Midterm   Reading assignments posted on......

Words: 1748 - Pages: 7

Programming

...variable total so it can hold integers. Initialize the variable with the value 0. Declare Real Price =0 7. Write a pseudocode statement that assigns the value 27 to the variable count. Count=27 8. Write a pseudocode statement that assigns the sum of 10 and 14 to the variable total. Set total= 10+14 9. Write a pseudocode statement that subtracts the variable downPayment from the variable total and assigns the result to the variable due. Declare Integer downPayment Declare Integer Total Declare Integer Due Set Due = Total - downPayment 10. Write a pseudocode statement that multiplies the variable subtotal by 0.15 and assigns the result to the variable totalfee. Declare subtotal Declare totalfee Set totalfee= subtotal*.15 Programming Exercises 6. Sales Tax Design a program that will ask the user to enter the amount of a purchase. The program should then compute the state and county sales tax. Assume the state sales tax is 4 percent and the county sales tax is 2 percent. The program should dis- play the amount of the purchase, the state sales tax, the county sales tax, the total sales tax, and the total of the sale (which is the sum of the amount of purchase plus the total sales tax). Hint: Use the value 0.02 to represent 2 percent, and 0.04 to represent 4 percent. totalState = amountPurchased * .04 totalCounty = amountPurchased * .02 total sales tax = totalState + totalCounty total with sales tax = amountPurchased + totalState +......

Words: 531 - Pages: 3

Programming

... | name | nationality | 01 | Pat | British | 02 | Hilary | British | 03 | Sven | Swedish | 04 | Pierre | French | | Event | eid | description | winner | 01 | running |   | 02 | jumping |   | 03 | throwing |   | | Competes | cid | eid | 01 | 01 | 02 | 01 | 03 | 02 | 04 | 02 | 04 | 03 | | Select the BEST answer from the following options based upon the provided data and data structures: Select one: a. There is a British competitor in every event. b. Pierre does not compete in any event c. Sven has been entered in two events d. Pat is competing in the jumping event e. Hilary has entered only the running event Question 1 If we write a program in a programming language and switch to SQL when we require to use the database, then the SQL environment in use is known as _______ SQL. Select one: a. Real - time b. Dynamic c. PL - d. Embedded Question 2 Embedded SQL is which of the following? Select one: a. Hard-coded SQL statements in a program language such as Java. b. The process of making an application capable of generating specific SQL code on the fly. c. Hard-coded SQL statements in a procedure. d. Hard-coded SQL statements in a trigger. Question 3 In JDBC, what represents a single instance of a particular database session? Select one: a. a thread b. an opened connection c. a closed connection d. a pipe Question 4 A relational database query normally......

Words: 4344 - Pages: 18