COMPUTER PROGRAMMING (SET-101) I N S TR U C TOR ENGR. IQRA JABEEN L E CT U RE R T E D , U E T TA X I L A E MA I L :IQRA .J ABE E N@UE T TA XIL A .E DU .PK Course Outline ▪Problem Solving and Algorithms ▪ Procedural Programming, Programming Basics: Program Structure, Basic Terms, Input /Output Statements, Comments, Simple Data Types, Arithmetic Operators, Expressions, Identifiers, and Reserved Words ▪ Loops and Decisions: Need for Decision in Problem Solving, ▪ Decision based on Conditions, Conditional Statement, Nested conditional Statements, Logical Operators, Repeating Parts of a Program, looping Statement, Structures/group data: ▪Embedded Structures/data. Storage of data in memory (e.g., linear and multidimensional arrays). ▪Software program, Divide and Conquer, needs for Subprograms, Functions, and Procedures, ▪ Passing Arguments by Value and Reference, returning Values from Functions, Overloaded Functions, Inline Functions, Default Arguments, Variables, Storage kinds and Visibility, Recursion, ▪Defining recursive functions. Arranging data in logically related groups to represent real-world entities. Books Textbooks ▪Deitel, Paul, and Harvey Deitel. C++ how to Program. Pearson, 2016. ▪Etter, Delores M., and Jeanine A. Ingber. Engineering problem solving with C++. Pearson, 2016. Reference Books ▪Python Programming: using problem-solving approach, Reema Thareja, Oxford University Press, 2017 ▪Java: A Beginner's Guide, Ninth Edition, 2022, Herbert Schildt, McGraw-Hill Education, ISBN 978- 1260463552 Grade Weightage Policy ▪Assignments: 10% ▪Quiz: 15% ▪Midterm Exam: 25% ▪Final Exam: 50% Student Behavior Expectations ▪Full attendance expected (75% ), except with prior-notified excuses ▪On-time arrival ▪Active participation ▪ Ask questions ▪ Answer questions from the instructor or students ▪Help each other in reviewing notes. ▪Promptly report/share problems/issues, including typos on slides, or misspoken words from the instructor. What is a Computer ▪ A computer is an electronic device that processes data and perform task according to the according to a set of instructions called a program. It consists of hardware (physical components) and software (programs and operating systems) ▪A computer is a programmable machine. This means it can execute a programmed list of instructions and respond to new instructions that it is given. ▪A computer is a programmable electronic device that accepts, stores, and processes data according to specific instructions (programs) to produce information. Why Computer Programming ➢ Computers can make calculations at a blazing speed without any error as compared to the humans. ➢ Example: calculate the prime numbers until 121. ➢ How long does it take? ➢ Do you do any error? ➢ ➢ Prime numbers: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 109, 113 Such a problem is so easy for a computer… Why Computer Programming Calculating the prime numbers until 121 Performing Task on Computer ➢ ➢ ➢ The first step in writing instructions to carry out a task is to determine what the output should be, that is, exactly what the task should produce. The second step is to identify the data, or input, necessary to obtain the output. The last step is to determine how to process the input to obtain the desired output, that is, to determine what formulas or ways of doing things can be used to obtain the output. Computer System ▪Basic Components of a Computer ▪Central processing unit (CPU): The brain of the computer that executes instructions ▪Memory (RAM): Temporary storage for fast data access. ▪Storage (HDD/SDD): Permanent data storage. ▪Input devices: Devices like a keyboard and mouse that provide user input. ▪Output devices: Devices like monitors and printers that display or output information What is a Computer Hardware Vs Software Hardware ▪ The computer equipment ▪ Includes printers, monitors, disk drives, etc. Software ▪ Programs that tell the computer what to do ▪ Examples - word processing, gradebook, tutorials, games, etc. What is a Computer Hardware Input Devices - Keyboard ▪ Most commonly used input device ▪Ergonomic : fit natural hand placement ▪Special keys ▪ Enter, Function, Ctrl, Alt, Num Lock, Esc What is a Computer Hardware Output Devices - Keyboard ▪ Monitor ▪Printer ▪Disk Drive ▪ Can also be input device ▪Modem ▪ Can also be input device Monitors ▪ Made up of tiny elements called pixels ▪ Each row of pixels is called a scan line ▪ Picture is displayed by an electronic beam lighting up certain pixels Computer Programming Languages Computer Programming Languages Software Programs: A set of instructions for the computer. Programming Language: is a formal system used to communicate instructions to a computer. It provides a way for humans to write code that a computer can understand and execute. ▪Programming languages Types: 1. Low-Level Languages 2. High-Level languages Computer Programming Languages Low-level languages: 1. Machine language: Binary codes (0s and 1s) which a computer can understand directly. 2. Assembly language: Used mnemonic codes instead of binary, requires an assembler (translator) to convert to machine code/object code. High-level languages 1. Procedural Languages: Focus on the sequence of instructions (e.g C and Pascal languages) 2. Object-Oriented Language (OOP): used object and class (e.g java, python and C++) 3. Functional Languages: focus on mathematical functions (e.g Lisp and Haskell) 4. Scripting Languages: Used for automation and Web development (e.g Javascript,python and PHP) Computer Programming Languages Machine Code ➢ ➢ Machine code, also known as machine language, is the elemental language of computers, comprising a long sequence of binary digital zeros and ones (bits). Sometimes referred to as machine code or object code, machine language is a collection of binary digits or bits that the computer reads and interprets. Machine language is the only language a computer can understand. Computer Programming Languages Assembly Language ➢ ➢ Sometimes referred to as assembly or ASL, assembly language is a low-level programming language used to interface with computer hardware. Assembly language uses structured commands as substitutions for numbers, allowing humans to read the code more easily than looking at binary. Although easier to read than binary, assembly language is a difficult language and is usually substituted for a higher language such as C. Computer Programming Languages Low-Level Language ➢ Low-level languages have the advantage that they can be written to take advantage of any peculiarities in the architecture of the central processing unit (CPU). Thus, a program written in a low-level language can be extremely efficient, making optimum use of both computer memory and processing time. ➢ However, to write a low-level program takes a substantial amount of time, as well as a clear understanding of the inner workings of the processor itself. Therefore, lowlevel programming is typically used only for very small programs, or for segments of code that are highly critical and must run as efficiently as possible. ➢ Computer Programming Languages High-Level Language ➢ High-level languages permit faster development of large programs. The final program as executed by the computer is not as efficient, but the savings in programmer time generally far outweigh the inefficiencies of the finished product. This is because the cost of writing a program is nearly constant for each line of code, regardless of the language. ➢ Thus, a high-level language where each line of code translates to 1-0 machine instructions costs only one tenth as much in program development as a lowlevel language where each line of code represents only a single machine instruction. ➢ Computer Programming Languages Compiler ➢ ➢ ➢ A compiler is a special program that processes statements written in a particular programming language and turns them into machine language or "code" that a computer's processor uses. After you write a program, your source language statements are compiled into machine code that is stored as an executable file. Scripting languages like Perl and PHP do not need to be compiled. Computer Programming Languages Debugger A special program used to find errors (bugs) in other programs. A debugger allows a programmer to stop a program at any point and examine and change the values of variables. How Programming Languages Work Compilation: Some languages (like C, C++) require compilation into machine code before execution. Interpretation: Some languages, like Python, JavaScript are interpreted line by line, making them easier to debug. Hybrid (Compiled +Interpreted): Java use combination of both Programming Languages and Their Uses Popular Programming Languages and Their Uses C: System programming, operating systems C++:Game-development and performance-critical applications. Java: Enterprise applications, Android development Python: Data Science, AI, and Web development JavaScript: Web development, front-end, and back-end. Swift: iOS and macOS development PHP: server-side web applications SQL: Database management Programming Languages and Their Uses Popular Programming Languages and Their Uses C: System programming, operating systems C++:Game-development and performance-critical applications. Java: Enterprise applications, Android development Python: Data Science, AI, and Web development JavaScript: Web development, front-end, and back-end. Swift: iOS and macOS development PHP: server-side web applications SQL: Database management Graphical User Interface A GUI is a graphical (rather than purely textual) user interface to a computer. ➢ Elements of a GUI include textboxes, buttons, pulldown menues, list and combo boxes ➢ Graphical User Interface DEV C++ IDE Important People in Computer Programming Important People in Computer Programming Computer Software Computer Software Collection of computer programs and related data that provide the instructions telling the computer what to do Two Types ▪System Software ▪Application Software Computer Software System Software ▪Provide the basic function for computer usage ▪Programs that support the execution and development of other programs. ▪Two types ▪Operating systems: Windows, Linux, MAC ▪Translation systems: A set of programs used to develop software, for example compliers and assemblers. Computer Software Application Software ▪Developed for a certain purpose/application ▪Examples ▪Microsoft Word ▪Spreadsheets ▪Presentation Managers ▪Drawing programs Program Development Cycle 1. Analyze: Define the problem. ◼ Be sure you understand what the program should do, that is, what the output should be. Have a clear idea of what data (or input) are given and the relationship between the input and the desired output. 2. Design: Plan the solution to the problem. ◼ Find a logical sequence of precise steps that solves the problem. Such a sequence of steps is called an algorithm. Every detail, including obvious steps, should appear in the algorithm. Program Development Cycle 3. Choose the interface: Select the objects. ◼ Determine how the input will be obtained and how the output will be displayed. Then create appropriate commands to allow the user to control the program. 4. Code: Translate the algorithm into a programming language. ◼ Coding is the technical word for writing the program. 5. Test and debug: Locate and remove any errors in the program. Testing is the process of finding errors in a program, and debugging is the process of correcting errors that are found. (An error in a program is called a bug.) 6. Complete the documentation: Organize all the material that describes the program Software Development Life Cycle ▪Software Development Life Cycle (SDLC) stages: 1. Requirements Gathering 2. Design 3. Software Development 4. Quality Assurance 5. Deployment Overview of Software Development Overview of Software Development Overview of Software Development Programming Stages Overview of Software Development Programming Stages Overview of Software Development Big Picture What is Programming ▪ A program refers to a set of instructions we provide to a computer to get an output. Telling a computer what to do. ▪ Programming refers to the process of writing such computer programs. ▪ Note that the words program, programming, and coding are used interchangeably in a broader sense. ▪ A programming language is a formal language that is used to write programs for the computer. Computer Programming First Computer Programmer Ada Lovelace is the first person to develop an algorithm for a machine. Algorithm and Flowchart Algorithm ▪ ▪ ▪ An algorithm is a list of instructions, procedures, or formulas used to solve a problem. The word derives from the name of the mathematician, Mohammed ibn-Musa alKhwarizmi (El-Harezmî), (780– 850). Pseudocode is a computer programming language that resembles plain English that cannot be compiled or executed, but explains a resolution to a problem. Algorithm and Flowchart ➢ Tools used to convert algorithms into computer programs: ◼ Pseudocode: An informal high-level description of the operating principle of a computer program. It uses the structural conventions of a programming language but is intended for human reading rather than machine reading. ◼ Flowcharts: Graphically depict the logical steps to carry out a task and show how the steps relate to each other. Programming Tools Flowcharts Pseudocode A graphical way of writing pseudocode ➢ Rounded rectangle – terminal ➢ Parallelogram – input / output ➢ Rectangle – actions ➢ Diamonds – decision / conditional ➢ Circles – connector ➢ Artificial and Informal language ➢ Helps programmers to plan an algorithm ➢ Similar to everyday English ➢ Not an actual programming language ➢ Algorithm and Flowchart Pseudo Code Algorithm and Flowchart Algorithm Flowchart Example Pseudocode Start Read A, B Calculate C = A*B Display C Stop Start - Terminal Read A, B – Input Calculate C = A*B - Action Display C - Output Stop - Terminal Example Flowchart Structured Programming Structured programming was first suggested by Corrado Bohm and Guiseppe Jacopini. The two mathematicians demonstrated that any computer program can be written with just three structures: sequences, decisions, and loops. ➢ Sequences: one command is executed after previous one. ➢ Decisions (selections): statement(s) is (are) executed if certain condition gives TREU or FALSE value. ➢ Loops (repetition): statement(s) is (are) executed repeatedly until certain condition gives TREU or FALSE value. ➢ Structured Programming Decisions Sequence ➢ Three selection structure in C programming: If ◼ If – else ◼ Switch ◼ Structured Programming Decisions/Selections Structured Programming Loops ➢ Three repetition structure in C programming: While ◼ Do – while ◼ For ◼ Structured Programming Loops ➢ Three repetition structure in C programming: While ◼ Do – while ◼ For ◼
0
You can add this document to your study collection(s)
Sign in Available only to authorized usersYou can add this document to your saved list
Sign in Available only to authorized users(For complaints, use another form )