CSC 1060 Week 02 Computers Systems, Problem Solving Intro C++ PDF

Summary

This document provides an introduction to computer systems and programming concepts, including topics like number systems (decimal, binary, hexadecimal), and ASCII codes. It also discusses the software development life cycle (SDLC) and offers examples of how to solve specific coding problems.

Full Transcript

CSC 1060 COMPUTER SYSTEMS & PROBLEM SOLVING OBJECTIVES AGENDA: WEEK 01 To understand computer basics, programs, and operating 1. Digitial Information systems. 2. Computers To describe the history of C++....

CSC 1060 COMPUTER SYSTEMS & PROBLEM SOLVING OBJECTIVES AGENDA: WEEK 01 To understand computer basics, programs, and operating 1. Digitial Information systems. 2. Computers To describe the history of C++. 3. Computer Numbering To understand the software development Systems lifecycle. To know programming style 4. ASCII & Lexicographical Order and documentation 5. History of C++ Apply coding standards to a program for 6. Intro to C++ conventional programming style. Insert comments to explain 7. C++ Program Execution code sections 8. TODO Write a C++ program. 9. Resources for Help COMPUTER NUMBERING SYSTEMS Number Base Used digits Example system Decimal 10 0,1,2,3,4,5,6,7,8,9 240 Binary 2 0,1 11110000 Hexadecimal 16 0,1,2,3,4,5,6,7,8,9, 0x7F A,B,C,D,E,F https://www.tutorialspoint.com/basics_of_computers/basics_of_computers_number_system.ht m 1 BYTE OF MEMORY = 8 BITS = 2 HEX DIGITS Decimal: 0 to 255 102 * 2 101 * 5 100 * 5 100's: 200 10's: 50 1's: 5 Binary: 00000000 to 11111111 27 26 25 24 23 22 21 20 128 64 32 16 8 4 2 1's: 0-1 Hexadecimal: 0x00 to 0xFF 161 * 15 160 * 15 16's: 240 1's: 15 INTRO TO COMPUTER ARCHITECTURE Store the Output the information results Input Process Storage Output Process the Take input information CONVERTING NUMBERING SYSTEMS # System Example Calculation Conversion Decimal 243 2*102 + 4*101 + 3*100 Base 10 200 + 40 + 3 = 243 Binary 11110011 1*27 + 1*26 + 1*25 + 1*24 + 0*23 + 0*22 + 1*21 + 1*20 Base 2 128 + 64 + 32 + 16 + 0 + 0 + 2 + 1 = 243 Hexadecimal 0xF3 15*161 + 3*160 Base 16 240 + 3 = 243 CONVERTING NUMBER SYSTEMS: 243 Decimal to Binary Binary to Decimal Decimal to Hex 243 / 2 121 R 1 1 1 27 = 128 243 / 16 15.1875 = 15 R 3 3 121 / 2 60 R 1 1 1 26 = 64 15 / 16 0.9375 = 0 R 15 F 60 / 2 30 R 0 0 1 25 = 32 0XF3 30 / 2 15 R 0 0 1 24 = 16 15 / 2 7R1 1 0 0 7/2 3R1 1 0 0 Hex to Decimal 3/2 1R1 1 1 21 = 2 F 15 * 161 = 240 1/2 0R1 1 1 20 = 1 3 3 * 160 = 3 11110011 243 243 TODO: convert 138 from decimal to binary to hexadecimal. Check your answer DIGITAL INFORMATION (KHAN ACADEMY) Complete the following lessons of Unit 1: Digital Information http://www.khanacademy.org/computing/computers-and- internet/xcae6f4a7ff015e7d:digital-information 1. Lesson 1: Bits and Bytes 2. Lesson 2: Binary Numbers 3. Lesson 3: Hexadecimal Numbers 4. Quiz #1 COMPUTERS (KHAN ACADEMY) Complete the following lessons of Unit 2: Computers http://www.khanacademy.org/computing/computers-and- internet/xcae6f4a7ff015e7d:computers 1. Lesson 1: Introduction to Computers 2. Lesson 2: From electricity to bits 3. Lesson 3: Logic gates and circuits 4. Quiz #1 5. Lesson 4: Computer components 6. Lesson 5: Computer files WHAT IS ASCII? HTTPS://WWW.EDUCATIVE.IO/EDPRESSO/WHAT-IS-ASCII ASCII - American Standard Code for Information Interexchange - assigns letters, numbers, characters, and symbols a slot in the 256 available slots in the 8-bit code. Most computers use ASCII to represent text, which makes data transfer between different systems possible. The standard ASCII text uses 7-bits to represent the characters. Other extended character sets use 8-bits to represent non-English characters. Try out the demo from the video using notepad and then view the properties for file size. Did you get the same results? ASCII AND LEXICOGRAPHICAL ORDER Type of Char Char values ASCII Codes Numberic Digits 0 to 9 48 to 57 UPPERCASE A to Z 65 to 90 lowercase a to z 97 to 122 Strings are a sequence of characters and characters are stored in memory based upon ASCII Lexicographical ordering is how strings compare to each other Order the following words in ascending order based upon lexicographical order: Hey, Hi and Hello COMPUTER PROBLEM SCIENCE SOLVING "Everyone in this country should learn to program a computer, because it teaches you to think." - Steve Jobs, 1995 "For a few it might lead to a lucrative career as so-called coders, but for everybody it'll teach them how to think, how to imagine, how to create. It'll provide a better understanding of the world and an indispensable foundation for life." - Ali Partovi "The person who does the work, does the learning." - Dr. Terry Doyle – Active Learning Deploy and Maintenance Start Here Planning / SDLC: Testing Analysis SOFTWARE Flexibility and DEVELOPMENT Expandability Portability LIFE Clarity of Code Developing / Implementation CYCLE Follow Specification Documentation Good Design Keep It Simple Design ALGORITHM DESIGN Step by step instructions that: 1. Solves a problem correctly 2. Solves the problem efficiently DESIGN CONSIDERATIONS: KEEP IT SIMPLE 1. Read the following article on How to Solve Coding Problems: https://www.freecodecamp.org/news/how-to-solve-coding-problems/ HOW is the problem solved? What are all the steps? What is the input and output What type of data is being stored by the inputs and outputs? What formulas are needed to calculate the answer? Computer formulas are more detailed than a math formula A computer formula must consider: Order of operations and data type being used: PEMDAS Instructions must be written explicitly DESIGN SOLUTIONS AND TESTING Flowcharts are a picture of the separate steps of a process in sequential order Pseudocode is an informal way of programming description that does NOT require any strict programming language syntax ( NO CODE; NO std::cout or std::cin). It is the text- based outline of the solution. All program solutions need to be tested using test cases (examples) created by the developer prior to developing the program. A test case is a test scenario, measuring functionality across a set of actions or conditions to verify the expected result. PROBLEM SOLVING Using the steps given in the article, solve the 2 problems (don't scroll down and review the answers until you've attempted to solve the problems yourself first. Self-Assessment: Complete the 5 questions practice section PROBLEM: GIVEN FAHRENHEIT, CONVERT TO CELSIUS Answer the following questions regarding the problem: What are the inputs? What are the Create some outputs? examples SOLVE PROBLEM #1 A single ticket to the fair costs $8. A family pass costs $25 more than half of that. How much does a family pass cost? HISTORY OF C++ C++, created as an extension of the C language, is commonly used for developing programs such as browsers, operating systems, games and more. 1979 – C with Classes: Bjarne Stroustrup of Bell Labs 1985 – C++ First Edition Commercially released 1998 – ISO/ANSI C++98 First standardization version 2011 – ISO/ANSI C++11 2014 – ISO/ANSI C++14 2017 – ISO/ANSI C++17 2020 – ISO/ANSI C++20 2023 – The next major revision (in progress) DEVELOPMENT CONSIDERATIONS Initial Development Maintenance Programming Language Flexibility and For CSC1060 always C++! Expandability Clarity of Design: Keep it Simple Portability Programming Time Clarity of Code Debugging/Testing Time Documentation Speed of Execution Size of Program and Data CODING STANDARDS BY ISO C++ ISO – International Standardization for C++ Should I use "unusual" syntax? NO General Guidelines to follow: Code is readable - Blank lines have no effect on a program. They simply improve readability of the code. Write code that is consistent for our class and style. Should I use using namespace std in my code? NO - Get over it and just type std:: always fully qualify std::cout Which is a better identifier name? Local variables start with lowercase letters and are meaningful! C++ RULES & STANDARDS 1. Every C++ program must have: 3. C++ is case-sensitive int main() { 4. C++ is a high-level language - return 0; everything has meaning! } 2. C++ symbols have meaning: variable names start with { lowercase letters code blocks are enclosed in 5. C++ is a strict type language curly braces and indented 6. Fully qualify standard identifiers: } #include main() is a function that using namespace std; performs the main program std::cout > …; ; ends each coding instruction statement COMMENTS Comments are internal documentation for a program Comments should NOT re-state the instruction, but ADD meaning and explanation to the algorithm. // Single line comments code instruction; // rest of the line comment C++ PROGRAM The function main is a special function in all C++ #include //input / output programs; it is the function called when the program is run. int main() { The execution of all C++ std::cout

Use Quizgecko on...
Browser
Browser