0% found this document useful (0 votes)
58 views

PPL Aakash

mbmmb

Uploaded by

DhruvKushwaha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
58 views

PPL Aakash

mbmmb

Uploaded by

DhruvKushwaha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 24
—— END TERM EXAMINATION 2018 EIGHT SEMESTER [B.TECH] PRINCIPLES OF PROGRAMMING LANGUAGES (ETCS-424) completely by 3 nite sets anda start sy:nbc grammar as follows: 62020 Riches ; In C++, we can Fractional Numbers, Big integers, sum = a+b; Here, variables “a” types. Hence the adatom gp is because the addition op only. class A { statements; int main { Aal,a2, a3; a3 = al ta! return 0; 1 In this example, we have are trying to add two objects “a™ “class A” using the “+” operator. 7 “+” is predefined to operate only on bi defined type, so the compiler generates overloading” comes in. Now if the user wants to make the op done by using the concept of “Operator @ overloading” is to use C++ operators with class meaning of operators really does not change been given additional meaning along with their exis ‘UNIT- Q2. (a) Define the terms syntax, Ans. Syntax: In a programming lan structure and crrangement of keywords, have any relationship with the meaning of the} grammar and structure of the programming ‘A line of code is syntactically valid and et Syntax does not have to do anything. are encountered after the pr "EE fi ; TP. University 12 Tech-Atash Books 2020-7 f2F08 are encount semantic ener nated during runtime of the sed ape ig Th tags aks sone, this term refers to the meres © Bazine elegy. Te te te ly analyzes and chooses in which Parameters or conditions, basic types of logic, or flow of contra, Enews ne logic, oF sequential ow ‘or conditional flow ie, oF repetitive how. (Sequential Flow) ome at of theprocessing, even some complex preblens on, ‘generally follow this elemeritary flow pattern, kgs ®) Selection Logic (Conditional Flow) If (condition) then: defining the ‘Al i, they have {Bnd of If structure) Double Alternative This structure has the form: 1f(Condition), then: Al a Else: govern the (Module B} ax doesn't {End if structure) d with the Multiple Alternatives This structure has the form: ‘If (condition A), then: {Module A] of | ae, Else if (condition B), then: fax [Module B) Else if (condition N), then: {Module N} A class helps in data bindi has attributes like spe he different br Object reeds and colors, ts An object is an entity with, instantiated at that time, the momaigl teract wi to know details oft For example, Dog is the object of the and behaviors, Encapsulation: information in a Encapsulation in @ rule and expose is important to encapsulate iftyou want yourmeney' nd gives you the money. It in binding data ng. In the above example, the int Abstraction: Basically, abstractioa ecause of large! Inheritance: Inheritance means i you inherit features and habits from your hods from one class to another. Com perties is one of the most ‘ou do the separation! san be reused in other classes. And this the area of the ability to display the mess characteristics at the same time, so this ding means to bind one thing to » linking some attribute of one object to There are two main types of binding: Saogunges the. Por empl, 6 Dog 2 chen ‘IP. University 4B. Tech}-Akash Bocks 2020-13 Dow are the sams As we know that each object has its - a bale on specie adres that other object ca use oa lots cn enn tfc 48 do whatever ae od base ote na a an objec: nas cemimancate wits each tne in intron ane ae Restate aetract datatype? Explain with te ip een example? () ee seis (ADT) is typ or clas) fr objets whose vir jan, having its properties Gatined by a set of values and a set of eperriose ‘The definition of ADT only mentions i den nt ape a eae lth thse pero lw impaesia all in it specify will be organized in and what algorithms will _ eee be used for implementing the operations. It is called “aburact” bossa ones from modifying the data The Cot : Process of providing only the essentials and hiding the details is known as c, the machine processes " nd functions wrapped Jeads to abstraction or nachine is hidden, iplexities and displays programming because ility to change things, affecting others, and mle wer of data type does not need to know how that data type is implemented, for the eons ite have boon using Primitive values like int, foat, char data types one ee the racteristics. Just like that these data type can operate and be performed on without any ides inherit the data and [9 of how they are implemented. the objects and their’ ‘So a user only needs to know what of Oops. implement functionality so that me of @ method * In Stack ADT Implementation instead of data being stored in each node, the “the shape, the area | Pointer to data is stored. F * The program allocates memory for the data and address is passed adth a form, Aspe +» The head node and the data nodes are encapsulated in the ADT. polymorphism is ‘The calling function can only sec the pointer to the stack. ei iaoies * Tha stackhead structure also contains a pointer to vp ano: one: Here ia OOPS TE of aumber ofeatrias curently ia sack, in the Aa * push ~Incertan clement at one end ofthe stack called tp * pop()— Remove and return the element at the top ofthe sto<% SES eee: without Vix j * peck() — Return the element at the top of the stack ye anged direet!’ | removing it ifthe stack is not empty. oa * size() ~ Return the number of elements in the stack. fale ime, then it # + isEmpty() ~ Return true if the stack is empty, others © a ae eo + isFull0 ~ Return true ifthe stack i fll, otherwise to 4, and due feats? pe ted ot Pkht Semester, Prine of Programming Languages = is, | Ds cern an inp hes oe ore a! 0 ‘Type conversion provides greater control over the ‘ress the programmer ean epee the dered data pe ‘sabiy. Type coercion ean rest in inexpeted rela ee performed 4 et redefined rules. Type conversion, on the ‘other hand, is more predictable, ’ a Programmer specifies the desired date type. ov nrc tl neaton n “9 ston omerting fa ght rt ds ee aa mS ‘Tipe oneson an i et i ef tena a a et it Se oe at ee ee te arn Seo her eno cn in nt nd te Se Sita ae ea a a © ‘a tees whne ta dae ela aha fm te bae oe | vk By dca lasd canbe aceasibe inthe child cage is contagn "ty made. By defnult vilbilty mode ie always sotto private, int are{100), return 0; ‘ved. lass namo : visibilty ed Babe Glass Barge Types of Visibility Modo in C4 There are total 3 types of visibility mod in Co that are, Derived Glass | Private Mode Public Mode Puble arnt ® delved singe aga Rane Jit 4d protected wiembaet oF the base cle When we inberit ler oe protect th deriv clans “mater ft ha Petite 4 Publio vtetbitiey mont Whew Wo inherit a derived publeviibity mode, the pub ‘hemor and a ‘e/nherlved oa puble members and prance fram a hae es nbets of the base elas Hor rapeetivly af the etal Sot otected mean 14-2020 Syntax- delete pointer variables Example. delete k; delete Ne; Q6. (b) What are wild) sures to handle them, Ans. Pointers store the mei 0 store the memory value which has been deallouat A pointer behaves like a why, they point a Here is an example of wild Example ‘include }/ Function Prototypo : oid swapstint x, int y); ot ee tin traries fine maing vopintere fT! ry oF data inta = 10, b = 20; intas 4 ; J} Pass by Values D8 = 10, b» 29, ed, That ix ; 1 Pass reference sswapx(a, b); sapslda, ayy } printft'a=fd bssed\n", a, by, PrN anid besa 4 5 | return 0; return 0; cont ) —7 |// Swap functions that swaps A Punction to swap two varia es ae | // two values by references Void swapxCint x, int y) oid swapxtint* x, int | { ( int t; | ye tex, | 1 Output: =20 y=10 a=20 b=10 ‘Thus actual values of a and b remain ‘Thus actual values of a and b get changed unchanged even after exchanging the after exchanging values of x and y. values of x and y. lisplaying In call-by-values, we cannot alter the Yalues of actual variables through function calls, In call by reference we can alter the values of variables through function ca Nalves of variables are passed by the] Polaler variables are necessary to def Simple technique, to store the address values of variable~ 21. () Define implicit and explicit sequencing with examples. G Ans. Sequence Control Sequence control defines the li implemented sequentially, in the Frpassing address ine-by-line implementation by which states" s) to the eauivalent order in which they occur in the =| | stn move out « sequence of read er nin operations, arithmetic oper ante ON iables. A sequence control srueere can be either implicit implicit Sequence Control ~ Implist Sequence control structures are the searnt2d by the language. Implicit sequence control is decided by the seq. she Natements inthe source coda or tne builtin implementation model, The :=0' peguance control structure tends to be in Consequence except that transformed by :he Prowiainner explicitly. An example ofan erie n sequence control includ x in many programming languages, the Physical sequence of statements provides the sequence control mechanism for execution, ‘ar tines anaes pgran een ad rane cacig ‘newer periormate character and tin pagantsing ine oe lock (6.5) way. ocess cess. same nt of more aple, ——a LP. Universi eh jeadlock can arise if the fo) “Akash, seeseaty Comite MOG fog A By Sylutual BxclUsion: TW oF mon, re Mons ty, can uso ata time) MFCO8 are n es a Hold and Wait: A process is holding at: nn No Preemption: A resource cannot po ta 0, releases the resource. een from 4 ~~ Circular Wait: A set of Processes arg =~ ty1B 1, Q2. (b) What is logic Programming pe 80h Othe jn Logie Program. 8 the dean Ans. Logic Programming is one of the. Computer Py the rogram statements express the facts and ruta Bia syst of formal logic. Ht, SHS SUIS rs mean ce bead and body are present. POF GEAIpIG| Ha head a. BL pe te by. Now if wo stato thal SHUHl Erie hea By, pas f all On the other hand, facts are like the rules, but wi ies is “His true”. Some logic; Programming 1; are known as purely declarative languages, Th what the program should accomplish, ‘There is ‘o perform the task. However, o imperative properties, problem H, perform Bi, ‘tel oad tthe eon snp ii nth Sag te ne i tried mie sept ‘rae n eck over fc . oan NNVErSItY Serieg Pe as ‘ ipo ora | cnet gy Wer 1 mem eg ial oymbl is expanded by applying a grammar rule that niin ‘etude Ta ciren are the symbols in he riht _ Sie DS si CCESS H’S ira Prasthe University Se PAPERS ——— ech} 'H SEMESTER miming Language anak hte sy mat pos rrp ‘nh ea po rate hes atv mats ph meet er ate aa na are Omir tpt init tn nee Socotra le Se tay eee ieee ermaciens asco ay meres Seco Soper whch not empty. In case

You might also like