multiple variables having the same value multiple variables having the same identifier multiple uses of the same variable

Similar documents
Programming Languages

A Fast Review of C Essentials Part I

BLM2031 Structured Programming. Zeyneb KURT

CS 314 Principles of Programming Languages. Lecture 11

Chapter 5. Names, Bindings, and Scopes

Computer Systems Lecture 9

Ch. 12: Operator Overloading

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe

Page. No. 1/15 CS201 Introduction to Programmming Solved Subjective Questions From spring 2010 Final Term Papers By vuzs Team

IMPORTANT QUESTIONS IN C FOR THE INTERVIEW

C++ Important Questions with Answers

Subroutines. Subroutine. Subroutine design. Control abstraction. If a subroutine does not fit on the screen, it is too long

CS1622. Semantic Analysis. The Compiler So Far. Lecture 15 Semantic Analysis. How to build symbol tables How to use them to find

Scope. CSC 4181 Compiler Construction. Static Scope. Static Scope Rules. Closest Nested Scope Rule

CS 314 Principles of Programming Languages

Every language has its own scoping rules. For example, what is the scope of variable j in this Java program?

CS 345. Functions. Vitaly Shmatikov. slide 1

Object-Oriented Principles and Practice / C++

COMP26120: Pointers in C (2018/19) Lucas Cordeiro

Program construction in C++ for Scientific Computing

by Pearson Education, Inc. All Rights Reserved. 2

Binding and Variables

Subprograms. Bilkent University. CS315 Programming Languages Pinar Duygulu

Short Notes of CS201

Software Engineering Concepts: Invariants Silently Written & Called Functions Simple Class Example

G Programming Languages - Fall 2012

CS201 - Introduction to Programming Glossary By

9/7/17. Outline. Name, Scope and Binding. Names. Introduction. Names (continued) Names (continued) In Text: Chapter 5

Chapter 3:: Names, Scopes, and Bindings (cont.)

Chapter 3:: Names, Scopes, and Bindings (cont.)

G Programming Languages - Fall 2012

Memory Usage 0x7fffffff. stack. dynamic data. static data 0x Code Reserved 0x x A software convention

Rvalue References as Funny Lvalues

Type Bindings. Static Type Binding

Review of the C Programming Language for Principles of Operating Systems

PROGRAMMAZIONE I A.A. 2017/2018

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS

Instantiation of Template class

Variation of Pointers

Review of the C Programming Language

Ch. 11: References & the Copy-Constructor. - continued -

P.G.TRB - COMPUTER SCIENCE. c) data processing language d) none of the above

Why Pointers. Pointers. Pointer Declaration. Two Pointer Operators. What Are Pointers? Memory address POINTERVariable Contents ...

Lecture 2: C Programm

Agenda. Peer Instruction Question 1. Peer Instruction Answer 1. Peer Instruction Question 2 6/22/2011

Data type of a pointer must be same as the data type of the variable to which the pointer variable is pointing. Here are a few examples:

Name :. Roll No. :... Invigilator s Signature : INTRODUCTION TO PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70

Programmiersprachen (Programming Languages)

What are the characteristics of Object Oriented programming language?

Pointers. 10/5/07 Pointers 1

The output will be: marks all or nothing. 1 #include <stdio.h> 2 main() { 3 int i; int j; 4 int *p; int *q; 6 p = &i; 7 q = &j; 8 i = 1;

Lecture 3: C Programm

OBJECTIVE QUESTIONS: Choose the correct alternative:

Introduction to C. Systems Programming Concepts

Imperative Programming

CA Compiler Construction

Introduction to C: Pointers

Note 12/1/ Review of Inheritance Practice: Please write down 10 most important facts you know about inheritance...

CSE 307: Principles of Programming Languages

CS240: Programming in C

Homework #3 CS2255 Fall 2012

Principles of Programming Languages. Lecture Outline


Compiler Errors. Flash CS4 Professional ActionScript 3.0 Language Reference. 1 of 18 9/6/2010 9:40 PM

CS 415 Midterm Exam Spring 2002

CS Programming In C

Declaration Syntax. Declarations. Declarators. Declaration Specifiers. Declaration Examples. Declaration Examples. Declarators include:

Data Types. Every program uses data, either explicitly or implicitly to arrive at a result.

Procedural programming with C

Variables and Bindings

FORM 1 (Please put your name and section number (001/10am or 002/2pm) on the scantron!!!!) CS 161 Exam II: True (A)/False(B) (2 pts each):

Fast Introduction to Object Oriented Programming and C++

G Programming Languages Spring 2010 Lecture 4. Robert Grimm, New York University

Functions BCA-105. Few Facts About Functions:

Work relative to other classes

UNIT II Structuring the Data, Computations and Program. Kainjan Sanghavi

CSE 374 Programming Concepts & Tools

QUIZ. What is wrong with this code that uses default arguments?

2.4 Structuring programs

Compiler Design. Computer Science & Information Technology (CS) Rank under AIR 100

Fundamental of Programming (C)

C Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites:

Project Compiler. CS031 TA Help Session November 28, 2011

Please refer to the turn-in procedure document on the website for instructions on the turn-in procedure.

CS 61C: Great Ideas in Computer Architecture. C Arrays, Strings, More Pointers

Informatica 3 Syntax and Semantics

ECE260: Fundamentals of Computer Engineering. Supporting Procedures in Computer Hardware

cs3157: another C lecture (mon-21-feb-2005) C pre-processor (3).

Chapter 3:: Names, Scopes, and Bindings

1. Describe History of C++? 2. What is Dev. C++? 3. Why Use Dev. C++ instead of C++ DOS IDE?

Unit 7. Functions. Need of User Defined Functions

OOPS Viva Questions. Object is termed as an instance of a class, and it has its own state, behavior and identity.

Applied Programming and Computer Science, DD2325/appcs15 PODF, Programmering och datalogi för fysiker, DA7011

Introduction to C++ Introduction to C++ 1

1. In COMAL language programs, parameters after name of procedure must be put in A. brackets B. back-slash C. insecure data D.

Chapter 5 Names, Binding, Type Checking and Scopes

Functions. Lecture 6 COP 3014 Spring February 11, 2018

C Programming SYLLABUS COVERAGE SYLLABUS IN DETAILS

The C Preprocessor (and more)!

Lexical Considerations

Transcription:

PART III : Language processing, interpretation, translation, the concept of binding, variables, name and scope, Type, l-value, r-value, reference and unnamed variables, routines, generic routines, aliasing and overloading, an abstractsemanticprocessor, run time structure. Casestudy- C run time structure ((MARKS (/2/3... N A B C _CHOICE (A/B/C/ TION Aliasing in the context of programming languages refers to multiple variables having the same memory location multiple variables having the same value multiple variables having the same identifier multiple uses of the same variable A Aliasing describes a situation in which a data location in memory can be accessed through different symbolic names in the program. ((MARKS (/2/3... N A In the evaluation of a computer language, all of the following characteristics should be considered except? Environment : S/w development tools

B C _CHOICE (A/B/C/ TION Efficiency readability hardware maintainance costs No Explanation ((MARKS (/2/3... N A B C _CHOICE (A/B/C/ TION 2 What is printed by the print statements in the program P assuming call by reference parameter passing? 0, 3 3, 3 27, 7 None of the above B Note the order in which parameters are passed. Inside func(, x will actually refer to y of main(; and y and z will

refer to x of main(. The Statement y = y + 4; will result in 4 and statement z = x + y + z will make z = 3 + 4 + 4 = 3 (because y and z point to same variable x of main. Since z refers to x of main(, main will print 3. ((MARKS (/2/3... N 2 Consider the following program Program P2 var n: int: procedure W(var x: int begin x=x+; print x; end procedure begin var n: int; n=3; W(n; end begin //beginp2 n=0; ; end If the language has dynamic scoping and parameters are passed by reference, what will be printed by the program? A 0

B C _CHOICE (A/B/C/ TION 3 None of Above Program will print 4. ((MARKS (/2/3... N A ((OTION_B C _CHOICE (A/B/C/ TION The- results returned by functions under value-result and reference parameter passing conventions o not differ iffer in the presence of loops iffer in all cases May differ in the presence of exceptions In call-by-reference evaluation, a function receives an implicit reference to the argument, rather than a copy of its value. This typically means that the function can modify

the argument- something that will be seen by its caller. Note that C doesn t support call by reference but call-byreference can be implemented using pointers. Call-by-value-result uses a combination of call-by-value and call-by-reference. Call-by-value-result works by creating local versions of the parameters passed in. However, the values in these local versions are copied back to the original arguments after the end of the procedure. ((MARKS (/2/3... N Values that are passed between program and its called subroutine are classified as A ((OTION_B C _CHOICE (A/B/C/ parameter. argument. global values. both a and b. TION

((MARKS (/2/3... N A B C _CHOICE (A/B/C/ TION Program subroutines are called by other programs. fixed variable. default constants. default variables. A No Explanation ((MARKS (/2/3... N Program routine which is used by one or more computer programs is classified as A B super-routine. subroutine. dimension routine.

C _CHOICE (A/B/C/ TION array routine. B ((MARKS (/2/3... N A B C _CHOICE (A/B/C/ TION Program used for interactive computing is Translator Executor Instructor Interpreter

((MARKS (/2/3... N A B C _CHOICE (A/B/C/ TION Program which translates high level program into machine code is classified as Compiler. Translator. Translating Analyst instruction analst A ((MARKS (/2/3... N A B C ynamic binding takes place during Translation Linking Loading the program

_CHOICE (A/B/C/ TION Execution ((MARKS (/2/3... N A B C _CHOICE (A/B/C/ TION Static binding takes placed during Translation Linking Loading the program All of the Above

((MARKS (/2/3... N A B C _CHOICE (A/B/C/ TION In which of the following mechanisms, types of all variables and expressions are fixed at compilation time. Strong Typing Weak Typing Static Binding/ early binding ynamic Binding/ late binding C ((MARKS (/2/3... N A B C In which of the following mechanisms, types of all variables and expressions are not known until runtime Strong Typing Weak Typing Static Binding/ early binding

_CHOICE (A/B/C/ TION ynamic Binding/ late binding ((MARKS (/2/3... N A B C _CHOICE (A/B/C/ TION In which of the following mechanisms, types of all variables and expressions are not known until runtime Strong Typing Weak Typing Static Binding/ early binding ynamic Binding/ late binding

((MARKS (/2/3... N A B C _CHOICE (A/B/C/ TION What is the scope of an external variable? Whole source file in which it is defined From the point of declaration to the end of the file in which it is defined Any source file in a program From the point of declaration to the end of the file being compiled ((MARKS (/2/3... N A B What is the scope of a function? Whole source file in which it is defined From the point of declaration to the end of the file in which

it is defined C _CHOICE (A/B/C/ TION Any source file in a program From the point of declaration to the end of the file being compiled ((MARKS (/2/3... N A B C Which variable has the longest scope? a b c #include <stdio.h> int b; int main( { int c; return 0; } int a; Both a and b

_CHOICE (A/B/C/ TION B ((MARKS (/2/3... N Scope of variable is related to definition of variable as:. Region of code within which variable value is valid and hence can be accessed. 2. No, relation with region where variable is declared its value is valid in entire scope. A B C _CHOICE (A/B/C/ TION 2 Both and 2 None A

((MARKS (/2/3... N Scope of variable is related to definition of variable as:. Region of code within which variable value is valid and hence can be accessed. 2. No, relation with region where variable is declared its value is valid in entire scope. A B C _CHOICE (A/B/C/ TION 2 Both and 2 None A ((MARKS (/2/3... N A variable that receives an assigned value is called an...

A B C _CHOICE (A/B/C/ TION L-value R-value Value Assignment A ((MARKS (/2/3... N A B C _CHOICE (A/B/C/ Recursion is sometimes called... Circular definition Complex definition Procedure Union A

TION ((MARKS (/2/3... N A B C _CHOICE (A/B/C/ TION 2 What will be the output of the following program? #include<stdio.h> int main( { int i = 0; printf("%d", ++(-i; return 0; } 0-9 None In C/C++ the pre-increment (decrement and the postincrement (decrement operators require an L-value expression as operand. Providing an R-value or a const qualified variable results in compilation error.

((MARKS (/2/3... N A B C _CHOICE (A/B/C/ TION 2 What will be output if you will compile and execute the following c code? #define max 5; void main({ int i=0; i=max++; printf("%d",i++; } 5 6 R-value required L-value Required It is clear macro constant max has replaced by 5. It is illegal to increment the constant number. Hence compiler will show Lvalue required. ((MARKS (/2/3... N Variable which uses same name in whole program and in its all routines thus best classified as Middle variable

A B C _CHOICE (A/B/C/ TION Global Variable Local Variable efault Varaible B No Explanation ((MARKS (/2/3... N A B C _CHOICE (A/B/C/ Use of recursion enhances logical clarity makes debugging easier reduces execution time reduces code size

TION No Explanation ((MARKS (/2/3... N A B C _CHOICE (A/B/C/ TION In which of the following parameter passing mechanism, the actual argument has to be a variable? Pass by value Pass by result Pass by value-result Pass by reference B No Explanation ((MARKS (/2/3... N The generic type in a template function

A B C _CHOICE (A/B/C/ TION must be T Can be T cannot be T for functions you create, but may be for C++'s built-in functions B Cannot be T ((MARKS (/2/3... N A B C _CHOICE (A/B/C/

TION