Fundamentals Of Programming Language I To acquire the

















![* Source Program in High Level Language (example. c) --> * [Preprocessor] --> Preprocessed * Source Program in High Level Language (example. c) --> * [Preprocessor] --> Preprocessed](https://slidetodoc.com/presentation_image_h/2beaeb1c187b390c887765a158eaabb3/image-18.jpg)




















- Slides: 38

Fundamentals Of Programming Language -I *

*To acquire the fundamental principles, concepts and constructs of computer programming *To develop competency for the design, coding and debugging *To build the programming skills using 'C' to solve real world problems

On completion of the course, learner will be able to– * Use modular programming approach in diversified problem domains * Apply programming logic to solve real world problems * Decide effectiveness of computer based solutions

* Unit I (02 Hrs): Introduction to Computer *Unit II (03 Hrs) : Programming language 'C‘ *Unit III (03 Hrs) : Decision Control Structures, loop control structures and Pointers in 'C': *Unit IV (04 Hrs) : Arrays, Functions and Strings in 'C':

*Block diagram of typical Computer, hardware, software. *Introduction to System Software- Operating System, Editor, Complier, Assembler, Linker, Loader. *Problem solving using computers *Introduction to computer programming *Introduction to program planning tools- algorithm, flowcharts, pseudo codes *Software Development Life Cycle *Introduction to open source operating systems and programming languages *Introduction to program development environments: BOSS and GCC.


* Output Unit * Input Unit * Storage Unit (Primary and Secondary) * Cache Memory * Flash Memory * CPU (ALU, CU, Registers) * Registers (PC, IR, DR, MAR, MBR, ACC, GPR)

Parameters Primary Memory Secondary Memory Speed Fast Slow Cost Expensive Cheap Storage Capacity Less More Connection with processor Closely Connected Directly Not connected

*There are two types of software. a) System Software b) Application Software. *System Software: System software is a computer software designed to provide services to other software. Examples: Operating System, Compiler, Assembler, BIOS etc *Features of System Software Speed is faster Machine Dependent Difficult to Design Difficult to Manipulate Difficult to Understand Smaller in size Less Interactive Generally written in low level languages

*Application software is computer software designed for end users to satisfy their requirements. Application software engineers are going to develop Application Software with the help of various system software designed by system software engineers. *Examples: Web browsers, spreadsheets, word processors, media player, Inventory Management Software, Ticket Reservation Software, Payroll Software, Microsoft Office, Internet Banking Software etc *Features: Speed is slower Easy to use Easy to Design Easy to Manipulate Easy to Understand Bigger in size More Interactive Generally written in high level languages (C, C++, JAVA etc)

*Operating System is an interface between user and computer hardware. *Ex. Microsoft Series OS, Unix, Linux, Mac OS etc *Linux is Unix clone written by Linus Torvalds. Linux is open source. *Functions of Operating System Memory Management Storage Management Device Management Process Management File Management Protection and Security

* Services of Operating System User Interface Program execution I/O Operations Resource Allocation Accounting Error Detection Communication File System Manipulation Protection & Security Types of Operating System * 1. Simple Batch Operating System * 2. Time Sharing Operating System * 3. Distributed Operating System * 4. Network Operating System * 5. Real Time Operating System

*Properties of OS Batch Interactive Real Time Sharing Network Parallel Distributed Clustered Hand held

* Editor: Sometimes called text editors is a program that enables users to create, edit, store and print text files. Ex. xedit, vi, emacs, gedit, sed etc Types of Editors: * Line Editors: * Stream Editors: ex. sed * Screen Editors: ex. vi editor * Word Processors: ex. MS word, Google Docx, Libre. Office Writer, Ted, Kword etc * Structure Editors: ex. Procompass editor, 4 d editor etc Note: Line and stream editors are suitable for text only documents.

*Preprocessors: Preprocessors programs perform Preprocessing is done before compilation. It includes operations like expanding macros, replacing header files with its corresponding source code, removing comments.

* A compiler is a software program that converts high-level source code into low-level object code (binary code) in machine language. This process of converting high-level program into machine language is called as compilation. Important task of compiler is the detection and reporting of errors and warnings. Phases in Compilation: * Lexical Analyzer * Syntax Analyzer * Semantic Analyzer * Intermediate Code Generator * Code optimizer * Code Generator

An assembler converts assembly language program into its equivalent machine language program. It also produces some information for the loader. An assembler is referred as compiler of assembly language. It also provides services of an interpreter. A linker is a program that combines two or more separate object programs and supplies the information needed to allow references between them Loader (one of the operating system utility) is a program which takes object code as input, prepares it for execution and loads the executable code into the memory. Loader is responsible for initiating the execution of the process.
![Source Program in High Level Language example c Preprocessor Preprocessed * Source Program in High Level Language (example. c) --> * [Preprocessor] --> Preprocessed](https://slidetodoc.com/presentation_image_h/2beaeb1c187b390c887765a158eaabb3/image-18.jpg)
* Source Program in High Level Language (example. c) --> * [Preprocessor] --> Preprocessed Program (example. i) --> * [Assembler] --> Equivalent assembly language code (example. s) --> * [Compiler] --> Object or Target Code in Machine Language (example. o)--> * [linker] --> Executable Code * [Loader] (example. exe)-->

1. Analysis: Understand (Define) the problem statement. 2. Specification: Specify what the solution must do. 3. Generic Solution: Specify problem solving approach, suitable data structures etc 4. Verify: Checking the correctness of the solution. Check whether the proposed solution really solves the problem. 5. Implementation: Implement the algorithm using any suitable programming language 6. Testing: Test your program. Your program should give legitimate output for all legitimate inputs. If not, find the cause and rectify them. 7. Deployment: Deploy at the end user side 8. Maintain: Modify the program to meet changing requirements.

Classification of Computer Problems: Sorting: Merge sort, Quick Sort, Bubble sort, Insertion sort etc. Searching: Linear Search, Binary Search etc. Numerical Problems: Algebra Problems Combinatorial Problems: Grouping, Ordering Geometric Problems: Computer Graphics, Visualization etc Graph Problems: Graph Coloring, shortest path etc

* *Algorithms *Flowcharts *Pseudo Codes

*Definition 1: An algorithm is a step by step procedure to solve a problem. *Definition 2: An algorithm is a sequence of unambiguous instructions for obtaining a required output for any legitimate input in a finite amount of time.

*Simple Language: Should be written in simple English. *Non-ambiguity: It should be clear and precise. There should not be any conflicts *Range of Input: should be specified, if not algorithm will move to infinite state *Definitive (Definiteness): Every statement should be definitive. *Multiplicity: Same algorithm can be represented in several ways. *Speed: should be fast *Effectiveness: Algorithm should do the right thing *Finiteness: Algorithm should terminate after performing required operation.

*Algorithm Addition (a, b) *//Problem Description: Addition of two numbers *//Input: Two integers a and b *//Output: Addition of a and b *Step 1: START *Step 2: Add a and b. Store result in c. *Step 3: Print c. *Step 4: STOP

*Algorithm GCD_Euclid (a, b) *//Problem Description: Algorithm for computation of GCD of two numbers a and b using Euclid’s method *//Input: Two integers a and b *//Output: GCD of a and b *Step 1: START *Step 2: Divide a by b. Let r be the reminder. *Step 3: If r is 0 then b is the answer. Print b. STOP. If r is not 0, Go to step 4. *Step 4: Set a=b, b=r and go back to Step 2.

*Algorithm Factorial (n) *//Problem Description: Algorithm for calculating factorial of a number *//Input: Integers n *//Output: Factorial of n *Step 1: START *Step 2: Initialize factorial=1 and i=1 *Step 3: If i>n, Print factorial and STOP. Else go to Step 4. *Step 4: factorial=factorial*i; *Step 5: i=i+1; *Step 6: Go to Step 3.

Definition: Flowchart is a diagrammatic representation of an algorithm. Flowcharts are helpful when explaining (Knowledge Transfer, KT) programs to others. Benefits of flowcharts are grasping will be easy and fast. Advantages of Flowcharts: *Effective Communication, Analysis, Coding, Debugging *Proper Documentation *Easy Maintenance

Sr. No Symbol Name Use Oval/Terminator Start and End of Algorithm 2 Rectangle Process, Assignment Statements 3 Parallelogram Input/Output 4 Rhombus / Diamond Making Decisions (if, then, else) 5 Circle Connector 6 Arrows Direction of the flow of Control 7 Predefined Process. Such as subroutine or 1 module 8 Display of Information


*Pseudocode is a simple way of writing programming code in English. It is not an actual programming language. Pseudocode does not necessarily have the correct syntax for any programming language and can’t be used immediately. Pseudocode can be used as base for writing programs in any programming language.

*Start *Input p and q *sum=p+q *print sum *Stop

*Start *Input a, b and c *sum=a+b+c *avg=sum/3 *print avg *Stop

Software Development Life Cycle (SDLC) defines the phases in the building of software. Phases of SDLC are * 1. Requirement Gathering and Analysis: All the relevant information required to develop software is gathered analysis of the same is done. * 2. Design: Defining overall system architecture * 3. Implementation or coding: Implement using suitable programming language * 4. Testing: Your system should give legitimate output for all legitimate inputs. If not, find the cause and rectify them. * 5. Deployment: Deploy the system at the end user side * 6. Maintenance: Modify the system to meet changing requirements of end user.

A SDLC model is a standardized format for planning, organizing and running a new development project. There are many SDLC Models are available. Some of the popular models are *1. Waterfall Model *2. Iterative and incremental development *3. Spiral Model *4. Agile Development *5. Rapid Prototyping *6. Unified Process

*Open Source Software (OSS): OSS is usually developed as a public collaboration. OSS's source code is made available to the public at free of cost. Anybody can get the source code from internet or from any other sources. You can use the source code for your use, for study purpose, you can modify if you want and redistribute it. *Open Source Operating System: *Open Source Programming Languages:

* BOSS (Bharat Operating System Solutions) is a GNU/Linux distribution developed by C-DAC, Chennai in order to benefit the usage of Free/Open Source Software in India and is customized to suit Indian's digital environment. * BOSS Variants * BOSS Desktop: An Indian GNU/Linux distribution customized for Indian environment. * Edu. BOSS: An educational variant of BOSS GNU/Linux focusing Indian schools. * Advanced Server: Server variant of BOSS GNU/Linux supports Intel and AMD architectures. * BOSS MOOL: MOOL aims at redesigning the linux kernel with minimal core OO components. * Source: https: //bosslinux. in

* The GNU Compiler Collection (GCC) is an integrated collection of compilers developed by GNU project. * The GCC includes front ends for C, C++, Objective-C, FORTRAN, Java, Go and ADA. * The Free Software Foundation (FSF) distributes GCC under the GNU General Public License (GNU GPL). * GCC is a key component of the GNU tool-chain. * GCC was originally written as the compiler for the GNU Operating System. * The GNU system was developed to be free (it respects the user's freedom) software. * The goal of GCC is to be a useful compiler for general use. * The design and development goals of GCC are to support new languages, new optimizations, and faster debug cycle, improved run time libraries

*1. To install gcc in fedora, run $sudo yum install gcc-c++ *2. Open any editor and give file name. ex. $vi hello. c *3. Press I to insert. Write complete code. *4. To save and quit: press ESC, SHIFT, : and type wq *5. To compile: $gcc hello. c *6. To run: $. /a. out