Programming Methodology - SE1012 Lecture Notes PDF
Document Details
Uploaded by Deleted User
SLIIT
Prof. Nuwan Kodagoda & Dr. Dinuka Sahabandu
Tags
Summary
These lecture notes cover programming methodology, concentrating on an introductory to computer science and C programming. The outline includes learning outcomes, module details, recommended books, and today's lecture topics from Chapters 0 and 1, relevant to the textbook Problem Solving and Program Design in C by Hanly and Koffman.
Full Transcript
Programming Methodology - SE1012. Lecture 1: Introduction to Computer Science and C Programming Basics Prof. Nuwan Kodagoda. Dr. Dinuka Sahabandu [email protected] [email protected] Pro Vice Chancellor Senior Lecturer (HG)...
Programming Methodology - SE1012. Lecture 1: Introduction to Computer Science and C Programming Basics Prof. Nuwan Kodagoda. Dr. Dinuka Sahabandu [email protected] [email protected] Pro Vice Chancellor Senior Lecturer (HG) Software Engineering Computer Science SE1012 – Module Learning Outcomes 1. Apply the knowledge of basic programming concepts and control structures 2. Design and develop programming solutions to problems 3. Create test cases to check the accuracy of the programs developed 4. Apply coding standards and best practices in software development 5. Identify and fix errors in a program 2 SE1012 – Module Outline Modes of Delivery Lectures – 2 hours per week Labs – 2 hours per week Assessments Weekly Lab Submissions - 10% Assignments – 20% Mid Exam – 20% (1 Hour) Final Exam – 50% (3 Hours) Module Pass Requirement To pass this module, students need to obtain a 50% in all ``Continuous Assessments” and an overall mark that would qualify for a `C’ grade or above 3 Recommended Books J.R. Hanly, E.B. Koffman, Problem Solving and Program Design in C, 7th edition, Pearson, 2012, ISBN: 9780132936491 P. Deitel, H. Deitel, C How to Program, 8th edition, Pearson Education Limited, 2015, ISBN: 9780133976892 4 Outline of Today’s Lecture Overview of Computer Science Computer Basics Software Development C programming ❖ Relevant readings from the textbook: Problem Solving and Program Design in C by Hanly and Koffman Chapters 0 and 1 5 Overview of Computer Science 6 Computer Science Study of computers and computational systems Key Areas: Algorithms and Data Structures: Designing and analyzing efficient ways to solve computational problems Computer Systems and Networks: Understanding how hardware and software interact in computer systems Artificial Intelligence and Machine Learning: Creating systems that can learn and make decisions Software Engineering: Developing reliable and efficient software applications Human-Computer Interaction: Designing user-friendly interfaces and improving user experience 7 Importance of Computer Science Computing powers essential daily activities (communication, transportation, healthcare, etc.) Drives innovation and efficiency in industries such as finance, healthcare, entertainment, and more Constant evolution of technology creates new opportunities and solutions for complex problems 8 Why Choose Computer Science? High demand for skilled professionals Competitive salaries and job stability Opportunities for innovation and impact https://www.linkedin.com/pulse/market-analysis-sri-lankas-software-industry-2023-wetechies/ 9 Traits of a Successful Computer Scientist Problem-solving skills and creativity Lifelong learning and adaptability Strong communication skills Ability to work collaboratively in teams 1 0 Relevant Disciplines in Computer Science 1 Jeri R. Hanly, Elliot B. Koffman, "Problem Solving and Program Design in C," 7th ed., Pearson, 2013. 1 Career Opportunities in Computer Science Software development and engineering Data science and machine learning Cybersecurity and information assurance Artificial intelligence and robotics Network administration and IT support 1 2 Computer Basics 1 3 What is a Computer? Computer is a machine that accepts data, processes it and produces output Categories of Computers: Personal Computers (PCs) Mainframes Supercomputers Embedded Systems 1 4 Components of a Computer Central Processing Unit (CPU) Main Memory i.e., RAM and ROM Secondary Storage e.g., Hard Disks, SSDs, Optical Disks Input Devices e.g., Keyboard, Mouse Output Devices e.g., Monitors, Printers 1 5 Input-Process-Output Cycle Input Process Output Keyboard Screen File Print Calculate Store File CPU 16 Computer Software Software is a set of programmes designed to execute certain task. Systems software: Operating systems, network tools, software development tools (e.g. compilers), Device Drivers Application software: Word processors, spreadsheets, databases, Computer games, Media Players 1 7 Evolution of Programming languages Machine language 1940’s 1950’s Assembly language High level languages, compilers etc. 1950’s Fortran, Cobol 70 & Emergence of well structured languages 80’s 70 & Pascal, Ada, C 80’s 1990’s Object Oriented languages C++, Java, Perl 1990’s 2000’s C#, Python, Ruby, Swift 1 8 Data Representation in Computer Memory Computers are digital and can recognize only two discrete states : on and off states Numbers are represented using binary number system Text is represented using ASCII values Letter A=1000001 19 Process of Developing a C Program 20 High Level Code into Machine Code Usually programs are written in a high level programming language (e.g., C, C++, C#, Java, Python, etc.) for humans to read Computers understand only one language, machine language (e.g., 0s and 1s – binary code), not (usually) human readable Software written in high level programming language is translated into machine language (binary code) for execution 2 1 Program Code Translation Object Code Source Code Translator (machine language code) Assemblers: Convert assembly language programs to machine language Compilers: Convert high-level language programs to machine language Interpreters: Directly execute instructions written in a high-level language, translating them into machine language line by line at runtime 22 Development 2 3 Software Development Understand the Problem Design a solution Test the solution Fix the solution Write and document the code 24 Understand the Problem In this stage , it is required to understand the Inputs – data to work with Output – desired results Additional information – like calculations, formulas, constraints 25 Design a Solution - Algorithm Algorithm: set of detailed, unambiguous, ordered set of steps to solve the problem Algorithms are expressed in pseudocode It is an English like phrases describing the algorithm steps Easy to read and understand. Algorithms are independent of any programming language Pseudocode should be Clear, Logical, Understandable, Consistent and Correct. 26 Pseudocode - Simple Example Write a pseudocode to input two numbers from the keyboard and calculate and display the sum BEGIN INPUT number1 INPUT number2 sum = number1 + number2 DISPLAY sum END 27 Test the Solution Perform the desk check – Use some known input values and check whether algorithm produce the desired output Do not rely on just one test case. Test the algorithm for all the possible cases Identifying errors and mistakes at early stage will save the time 28 Fix the Solution Read the problem definition again to identify the missing points Refine the algorithm to accommodate the changes Perform the desk check again Repeat these steps until desk check is passed 29 Write and Document the Code Convert algorithm into a program using a Highlevel language. Each algorithm step will require one or more program statements Write the documentation so the code can be easily maintained. 30 Writing a C program 3 1 History of C C is a high-level programming language developed in 1972 by Dennis Ritchie at AT&T Bell Laboratories. C was designed as a language in which to write the UNIX® operating system. C is a popular programming language among the scientists C99 and C11 are revised standards for C programming language that refines and expands the capabilities of C. 32 How to write a simple C Program Design and write your algorithm (pseudo code) Create a text file with the extension of.c Compile the source code into byte code Execute the byte code 33 Pseudocode Example BEGIN OUTPUT "Hello World!" END 34 A Simple C program 1 #include 2 int main(int argc, char* argv[]) 3 { 4 // following line prints a message 5 6 printf(“Hello World! \n”); 7 8 return 0; 9 } 35 Pseudocode to C program 1 #include 2 int main(int argc, char* argv[]) 3 { BEGIN 4 // following line prints a message OUTPUT "Hello World!" 5 END 6 printf(“Hello World! \n”); 7 8 return 0; 9 } 36