You are on page 1of 21
ate \. — rinstitute of Tec P.anveor ogy: Kanpur IMPORTANT QUESTIONS LIST Programming for Problem Solving(KCS-101/201) hati digttal computer? Draw block diagram of digital computer and explain each component of it 2. Explain memory hierarchy with the help of diagram. 3, What isan Operating System? Discuss various functions of Operating System 44 Whatis structured prograrnming? Explain and give examples of relevant constructs Using pseudo-code. Highlight the advantages and disadvantages of structured programming SS. What do you mean by an algorithm? Explain the properties of algorithm. €._ What do you mean by flowchart? Discuss the efferent symbols used in flowchart Discuss advantages and limitations of flowchart. (i) Draw a flowchart to find the factorial of the given number. (i) Write an algorithm and draw a flowchart for finding the arBest among 3 numbers. {ii) Draw a flowchart to sum first n natural numbers. {iv) Write an algorithm and draw a flowchart to check leap Yea" {v) Develop an algorithm to dspla all prime numbers between given range (ui) Draw flowchart to check that entered number is palindrome or not {vii) Draw a flowchart to print Fibonacci series of n terms. 7. Differentiate between: {i) System Software and Application Software (i) Low-level, middle and high level languages {iil) Compiler, interpreter. {iv) BOS, Windows and UNIKO:S (list 5 commands of DOS and UNIX 0s) 8. Convert the following: Decimal —to ——~Binary Binary —to~-~ Decimal Octal -—to Decimal Hexadecimal——to—-Decimal ete. 9, what are diferent datatypes in language? Explain rangesmemory sizeof each with Is format specifier. 110. What are operators? Explain different types of operators used in © 41. Describe precedence and associativity of operators 412, For, While and do-while loop with exarrples. 113. Differentiate between break and continue with examples: 14. Differentiate between switch and if-else with examples. 415. What are functions? What are advantages of using multiple functions Ina program? 46. Caplan the difference between parameter passing mechanlsms tothe function? WAP to sR 2 numbers using “call by value” and “call by reference, 117, What do you mean by recurslon? What are the main principles of recursion? 1B. Define the various storage classes nC, Explain each with sultable examples By. Sarvesh Kr. Soni (Asst. Prof, Department of IT) Page 1 er Singh Institute of Technology: Kanpur 419, What do you mean by an array? In what way array is diferent from an ordinary variable, 20. Whats a pointer in C? How are they used, explain with the help of sultable examples, Also discuss ts advantages and disadvantages. 21, Explain Dynamic memory allocation. Differentiate between malloc) and calor) functions 22, What are structures? Write the syntax of structure, How can the size ofthe structure be determined? Which operator is used to access the member of the structure? 23, bifferentiate between structure and union. 24, What do you mean by € pre-processor? Deine the function of 9 pre-processor, Explain the pre-processor directives. 25. What is macro? How is it substituted? Write a program that illustrates the use of macros with argument. 26, Explain the different file opening modes in C. Discuss basic file handling functions. Programs List : 4. WAP to check whether a given year is leap year or not. 2. WAPto calculate the factorial ofa given number (using loop and recursion). 3. WAP to find out whether a given number is prime or not. 4. WAP to display all Prime numbers between a given range m and n. 5, WAP to print and sum the Fibonacci series of n terms using recursion. 6. 7. 8 8 WAP to check whether a given number is palindrome or not. WAP to check whether a given number is Armstrong number or not. |. WAP to print Fibonacci series of n terms using recursion. WAP for Linear Searching to search a number in a given array. 410. WAP for Binary Searching to search a number in a given array 11. WAP for Bubble sorting to sort the numbers in a given array. 12. WAP to reverse the given string without using strrev() function. 13, WAP to find number of words in a given string. 14, WAP to check whether given string is Palindrome or not. 415. WAP for matrix addition. 16. WAP for matrix multiplication. +) WAP to store the records of n students and display the Names of students in merit Iist of top 10. Each record ‘consists: {RolINo., Name, Branch, Year, Mu:ks} 18, WAP to store the records of n Employees of company. Display the list of those employees who are working in “Computer Science” department and whose salary >= 25000. Each record consists of: emp_! department, salary. 19. WAP in C to copy the text of one file to another. 20. WAP to store the records of students {Rollno, name, branch, marks) in a file “record.cloc” EE ord By Sarvesh Kr. Sonl (Asst. Prof. Department of IT) Page % “To \ A ae Ls Te amedyse. om all gcoedthenn PRO tS, ing The naenanget” of deegorereced ( uth ch Thme } Ne mio Staxege ) mredeclecl te execute Nida omits Geni LENE ele CN cae ene WM es wo L, dn other wosels , tthe “0- of amerching unstsiiBe yrhich o eee executes cling ath execilion yy called dime Comper bhi number Bus prrimertly olepenclonitt om Ht Ase of He porogeeum's inp eamck Aer algorithms ujecd- e Space Compilerity t— Spee complexity °} alopxtttmn ty Gumourst Of Compaen. rneyiiass < « 2 the acecution » Phat mae seequitel abo pop? Be Types Of Tere Comploxity de> a oar ee (1) work cose Pe ee ate. hematas he behayiov of Ste abgasitim wert she woos con @ by To dendh the grclor, of comply a UAE thoes. by pes af WmotettL ond 1) Big-oh Notion ( O) Vi) Dmega Noteikion (2) 1) There Noteition (6) # Notettons 4 Complexity me 1 {) Big-Oh_Noteitewr, — the Bi oh motakion whee “0! Gtewls fous oreles of", 24 comeerenel eae hoppens Jor ie Hoge volwe of L Big oh mokartor shout the Upper howell of the comptes . Ls wotan -2apreitinn Consh compleyity, ug fy Big- oh ; mabliplierd? coe ignore : So om O4n) algo: AY equivedent to O(n) Time 94 com be expe eS orporenssenl 15 [Fen < cg) jose ii) -2 Notetion Bro ys poconroles the ———_ Aproot-bourroh of the complexity, of en algo. e @ Deg es o a deudluitelh notertion whieh Upper os, well ou lower bourd of thee oes ce . 1. Input: Tis isthe process of e tMkss dan from us tothe compute nan organized manner or processing ne: Mette he ip unit 2 ast that the data has to be provided to CPU with the same speed. Therefore the data is first stored in the storage unit the above functionality. It Provides space for. storing data and instructions, The storage unit performs the following major functions _AuGats and instructions are stored here before and after processing, + Intermediate results of processing are also stored here 3: Processing: The task of performing operations like arithmetic and logical operations is called processing. The antral Processing Unit (CPU) takes data and instructions from the storace anivard make: a sorts of calculations based on the instructions given and the type of data provided: Iis then sev back cote storage unit. 4: Output: This is the process of producing results ffom the data for getting useful information Similarly the Output produced by the computer after processing must also be kept somewhere inside the computer before being Siven to you in human readable form. Again the output is also stored inside the computer for further processing, 5. Control: The manner how instructions are executed and the above operations are performed Controlling of all Soe oaeyike inbut Processing and output are performed by control unit. I takes eare of sep by step processing, fall operations inside the computer. |i order to carry out the operations mentioned in the previous section the computer allocates the task between its ‘arious functional units. The computer system is divided into three separate units for its operation, They are 1) Arithmetical logical unit 2) control unit. 3) Central processing unit. * Arithmetical Logical Unit (ALU): Afer you enter data through the input deve it s stored in the primary storage unit. The actual processing of the data and instruction are performed by Arithmetic Logical Unit ‘The major operations performed by the ALU are addition, subtraction, multiplication, division, logic and comparison, Data is transferred to ALU from storage unit when required, After processing the output is returned back to storage unit for further processing or getting stored, * Control Unit (CU) The next component of computer is the Control Unit, which acts like the supervisor seeing that things are done in proper fashion. Control Unit is responsible for coordinating various operations using time signal. The control unit determines the sequence in which computer programs and instructions are executed. Things like processing of programs stored in the main memory, interpretation of the instructions and issuing of signals for other units of the computer to execute them. It also acts as a switch board operator when several users access the computer simultaneously. Thereby it coordinates the activities of computer's peripheral equipment as they perform the input and output. Z Central Processing Unit (CPU) The ALU and the CU of a computer system are jointly known as the central processing unit. You may call CPU as the brain of any computer system. Computer H/w : It can be divided into 3 major parts 1, cpu 2. Memory (RAM) 3. 0 Processor CPU has > Sarva Gr Somi(A8s Po, xp oF 1) 2 Arithmetical & logical unit for data manipulation No. of registers for data-storage © Control eireuits to fetch & execute Instructions MEMORY UNITS:- The memory of C.P.U. is register which is very small and very fast and also costly. Hence it needed memory for storing information, Generally two type of memory uses in computer systems. 1, Main memory also ealled primary memory 2. Secondary memory 1, PRIMARY MEMORY (MAIN MEMORY): Main memory is directly access by C.P.U. RAM (Random Access Memory made of semiconductor) are used as main memory. Itis called Random because C.P.U. can access any location of memory any time. Its access time 10 nano second (n.s.). Other semiconductor memory is ROM (Read Only Memory. ROM is permanents memory, difference can be understands as bellow.) TYPESOF RAM:- Basically two types of RAM exits, 1, Static RAM > SRAM 2. Dynamic RAM — DRAM STATIC RAM:- The static RAM retain information as long power supply is on. Static RAM made of D flip ~ flops without use of capacitor. There is no need to reftesh it It is faster and costly than D-RAM. DYNAMIC RAM:- Dynamic RAM are made of transistors and capacitor. Since capacitor has leakage property hence it needed charge at random time (For few second). That's why itis called dynamic RAM. Slower but higher capacity than DRAM. DIFFERENCE BETWEEN SPRM AND DRAM a S.N.SRAM DRAM zat] 1, SRAM made of flip-flops. DRAM made of transistors and capacitors. 2, SRAM needs 6 transistors for storing DRAM needs only one transistor fop storing 3. bits. 1 bit. SRAM is costly, 6 transistors require DRAM is cheaper only one transistor require for RIW facility. for R/W facility. ‘Any RAM can be faster by using Cache memory between C.P.U. register and main memory. Another RAM is EDORAM — Extended data output RAM SDRAM — —*Synchronous DRAM (Same clock SGRAM — — Synchronous Graphics RAM rate a C.P.U) DDRSDRAM — Double Data Rate DRAM (Transfer data from both edges of clocks ) Random Access Memory (RAM) _ [Read Only Memory (ROM) 1. [tis volatile memory ie. when 1. ROM is permanent, The stored information does power goes off the stored information jot loss while power supply goes off Also called lost. ‘non volatile. 2. RAM possessor random manner 2, ROM not possessor random manner (but may be). ite. any information access randomly. 3. ROM can not write it can read only. 3. RAM is read Avrites memory ie. _[f. ROM less costly as compare to RAM for large any information access Randomly, volume. 4. RAM is much costly as compared to ROM large volume, Sorveth Ke Soni (Ast of, Dene oF TT) 5 ROME: Rom is stand for read only memory Tt is nonvolatile memory. The information stored in itis not lost even if power supply goes off is used for Permanent storage. It also possesses Random property. ROM is accessible to users, The contents of Rom decided bby manufacturers ROMS store monitor, assembler, debugging package, function table such as sine, cosine, logarithm, square root, etc. Example of RAM ‘Toshiba Mask ROM. ‘TCS 534000, 512kx 8 bits ‘TYPES OF ROM PROM:- Stand for programmable ROM. Its content decided by user not manufacturer. User can store information by special equipment called Prom programmer. PROM is more costly. Example:- 745287 EPROM: Stand for erasable PROM. The stored information can erased by exposing it to high intensity short wave ultraviolet light about 20 minutes. It not convenient be causing for removing information from EPROM it is necessary separate EPROM from chip. EEPROM: It is stand for Electrically erasable PROM also known as EAPROM (Electrically alterable PROM).The information can erase byte by byte. It limit for any EEPROM again a few milliseconds. There is limit for any EEPROM again and again reprogrammed. EPROM requires 21 volt pulse for writing or erasing and 5 volt for read operations. Basic Hardware Components Program: A sequence of instructions for the computer is called a program. The data that are manipulated by the program ereate the database, 1. System software-I i whi i ‘The most obvious type of system software is operating system and device drivers. ‘Save Ke Son (Ast Pr Det fT) hi which helps to maintain and protect the computer system but does not directly interface with the hardwar 2. Applications software (also known as ‘apps') are designed to allow the user of the system to complete specifie task(application). They include programs such as web browsers, MS office, games, media players and so on. wy Faster, Smaller ~GBs-TBs ~GBs-TBs Slower, Bigger Speed | Memory Deseription > = Registers are embedded inside the CPU. They have very less capacity but lastest speed. CPU uses some specific registers like PC (program counter), IR \Gnstruction register), MAR (memory address register), MDR (memory data register) and some GPR (general purpose registers),Ax(Accumulator register). Fastest [Register [Cache memory is memory actually embedded inside the CPU. Cache memory is very fast, typically taking only once cycle to access, but since itis Faster Cache embedded directly into the CPU there is a limit to how big it can be. In fact, Ithere are several sub-levels of cache memory (termed L1, L2, 13) all with lightly increasing speeds. [Alt instructions and storage addresses for the processor must come from Slower IRAM. Although RAM is very fast, there is still some significant time taken than [RAM for the CPU to access it (this time is larency). RAM is stored in separate, {Cache tes chips attached to the motherboard, meaning it is much larger than \e memory, IWe are all familiar with software arriving on a floppy disk or CDROM, and ving our files to the hard disk. We are also familiar with the long time a lowest [Disk gram can take to load from the hard disk -- having physical mechanisms Isuch as spinning disks and moving heads means disks are the slowest form of rage. But they are also by far the largest form of storage. FLOPPY DISC:- Floppy disc have single disc and R/W heads in floppy Dise drive, The sized floppy disc is 1.44MB. Two type of loppy dise depend on size, 1, 3.9 INCH FLOPY DISC 1.44 MB 2, SINCH FLOPY DISC Suresh Kr Soni (Ast Pro, Dept of TH) 5 a ” Now w day 7/2 inch dise are using 5 inch dise are not used today. Both drive require different drive for read and avrite operations 3.5 inch drive denoted by drive ‘A° 5 inch drive denoted by drive ‘B” ort The optical DI VICES: Optical disc is same as magnetic disc but it does not contain magnetic foil at its surface made by other type of materials. A disc surface PIT and LAND made by laser beam. The PIT denote ‘1? and LAND denote ‘0" . When laser beam exposing on surface of disc by R/W head. The reflected beam suler different distance from PIT and LAND as shown in figure .By this property head can differentiate between PIT (1) and LAND (0), ETIC Magnetic dise include floppy disc and hard disc. Working principle of both is same. Data stores on dise surface. Its surfaces divided into co centric track and each track divided into sectors. The dise is ‘mounted on a rotary drive (D.C. Motor) to rotate disc, After read data R/W head remains stationary, while dise rotate continuously. All tracks contain same number of bytes. Hence track which is nearer to centre is denser (complex) than outer tracks. A disc may other structure that a sector contains different no. of tracks. Hard disc is combination of more disc in co centric frame as shown below. Read/write Head. The data can be access only with read/write heads. All dise are rotating continuously and head move forward and backward direction as required. Size of hard disc is varying in few GB now in TB. CACHE MEMORY; - Cache memory placed between C.P.U. and main memory. It consists of static RAM. Its aecess time is about 10 n.s. Cache memory help to provide data to C.P.U. as needed. Since Ram can not provide as speed as C.P.U. need, so Cache are use to remove this difficulty SECONDARY MEMORY: - Secondary memory is also known as permanent strong, It stores files (Text, Audio, Vedio etc) and other format of data. The stored file transfer from secondary memory to Primary memory when needed by computer for execution of any program because any file can not executed in secondary memory it can be ‘executed any Primary memory (RAM).Two type of Secondary memory used today © Magnetic memory © Optical memory MAGNETIC MEMORY: - Magnetic memory is not volatile it is used for backup memory. Digital data 0 and 1 store on magnetic coating film. The binary digit depends on direction of magnetization of very small area of magnetic film. There are two technique used for storing data. © Longitudinal recording, © Vertical recording ‘AnO. acts as an intermediary between the user of a computer S/W & the computer Hw. “The purpose of an O'S. is to provide an event. in which a user can execute programs in a convenient & efficient manner.” O'S. is a Siv which controls or operates the H/w of computer. Hiw of computer: CPU, memory, 1/ devices Etc. (touch & feel) Siw of computer _: Packages for different applications. compliers of different Languages + Others, Information/data (e-mail, ...) So OS. is just like a government, it does nothing (important) useful functions by itself. It only provides an environment within which other programs can do useful work. Savon Kr. So (Ass Pot Dep of IT) 8 An operating system, or "OS," is a_system software that communicates with the hardware_and allows. other Drowiams to Tun, Ut has the fundamental files your computer needs to boot up and function. Every deskiop ‘and smart phone includes an operating system that provides basic functionality for the device 5 win 2000,Win xp, win 8, Unix, Linux, Android et. Important functions of an operating system: A + Memory Manageme ‘© Processor Management ‘© Device Management «File Management Security Management # Control over system performance Job accounting ‘© Error detecting aids © Coordination between other software and users ss E aa “3 4, . am Batch OS :The users of batch operating system do not interact with the computer directly. Each veer prepares his job on an offline device like punch cards and submits it to the computer Persie Main problems are - Lack of interaction between the user and job, CPU is often idle Real-time OS: A real-time operating system is a multitasking operating system that alms at executing real- time applications. Real-time operating systems often use specialized scheduling algorithms so that we can perform multiple tasks simultaneously, The main objective of real-time operating systems is their quick and predictable response to events. They have an event-driven or time-sharing design. Fx- ‘VxWorks, MARS, RTLinux Multi-user OS: A multi-user operating system allows multiple users to access a computer sySen" at the ate ey Time-sharing systems and Internet servers can be classified as multi-user systems, Singleser Operating systems have only one user but may allow multiple programs fo run at the same time.EN- UNIX,Main-Frame,Supercomputer. Distributed OS: tributed operating system manages a group of independent computers and makes thm appear to be a single computer. The development of networked computers that could be Unked and aac ipeate with each other gave rise to distributed computing, Distributed computations are carrie! out cormchan one machine. When computers in a group work in cooperation, they make v distributed ‘system.Ex-NFS-Andrew, Amoeba Surveth Kr Son (Ass Prof, Dept of 11) 7 | ‘The Fundamental knowledge needed to solve problems using a computer is the notion of an algorithm. ‘An Algorithm is a precise specification of a sequence of instructions (tells what task is t0 be executed) t0 © A typical programming task can be divided into two phases: ordered sequence of steps th: ce of steps is called an algorithm some p) des ibe solution of problem ming language Problem. Algorithm Variable 10001001 11110000 10000001 00000111 Flowchart Programming (Basic, VB,C, C- language Joa Pel.) be carried out in order solve a given problem”. Features of a good algorithm: 1. Finiteness: An algorithm must terminate after a finite number of steps and further each step must be executable in finite amount of time Definiteness (no ambiguity): Each steps of an algorithm must be precisely defined; the action to be carried out must be rigorously and unambiguously specified for each case. 3. Inputs/ Output: An algorithm has zero or more (but only finite), number of inputs and (atleast Noutput Effectiveness(efficient): An algorithm should be effective. This means that each of the operation to be performed in an algorithm must be sufficiently basic that it can be done exactly and in a finite length of time, A ELOWCHARTS: Flowchart is developed for showing the steps involved in a process(algorithm).. Suveth Kr. Soi (As Prof, Dept of 11) © A flowchart is a dia ‘© Flowchart combines symbols and flow lines, to show the operation of an algorithm in a figure. ed by arrows. made up of boxes, diamonds and other shapes, cone: Flow chart Symbols Symbol Na: Function « Startyond dn eesyserenents = sere a eee on ae i) Swapping of given two numbers without using third variable. ALGORITHM: Stepl: Start Step2: Input a,b Step3: Set a=a+b Step: Set b=arb Step 5: Set a=arb Step6: Print the result a,b 5 Display aa Step7: Stop sass Convert temperature from centigrade to Fahrenheit. Algorithm: Step |: start Setp 2 : read temperature in centrigrade c> Step 3: caluculate Fahrenheit = 32 + (centigrade * (1.8); Step 4 : display centigrade and Fahrenheit Step 5: stop Flow chart Fah = 32+(cent' Sarvesh Kr Soni (As Prof, Dept of (1) 10 Structured programming, sometimes knov prog It is a subset of procedural programming that enforces a logical structure on the program being written to make it to understand and modify. more efficient and ea It is A technique for organizing and coding computer programs in which a hierarchy of modules is used, each having a single entry and a single exit point. In Struct.Prog., control is passed downward through the structure without unconditional branches to higher levels of the structure. ‘Three types of control flow are used: ‘+ Sequential, + Iteration (repeating). Structured programming frequently employs a top-down design model, in which developers map out the overall program structure into separate subsections. A defined function or set of similar functions is coded in a separate module or sub module, which means that the code can be loaded in to memory more efficiently and that modules can be reused in other programs. After a module has been tested individually, it is then integrated with other modules into the overall program structure Top down approach and Stepwise refinement With the top-down approach, we start with our top-level program, then divide and further sub-divide it into many different modules. The division process is known as stepwise refinement. As we design each module, we will discover what kind of sub modules ‘we will need, and then continue to program those. Afier programming our smaller sub modules, we will group them together into the larger module. * The key to stepwise refinement is that each module should end up doing only one task. © One advantage of the top-down approach is that we sec the full picture at first. ‘+ Therefore, the top-down approach is suitable for larger problems. Suresh Kr Soni (Ast ro, Dept oF 11) as ig

You might also like