100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Class notes

COS1511 - Introduction To Programming 1 and Logic Class Notes.

Rating
-
Sold
-
Pages
25
Uploaded on
05-04-2022
Written in
2021/2022

COS1511 - Introduction To Programming 1 and Logic Class Notes.Processor Components  ALU -- Arithmetic Logic Unit o Performs all arithmetic and comparisons  Control Unit o Controls all operations to be performed  Main memory o Holds the data and the programs  Process  Data is picked up from the input device by the control unit  The control unit then stores it in main memory  How do we know where it’s stored?  Addressed -- identify the spot in memory where the variable is stored  Names can be given to the addresses  Main memory is measured in BYTES  Each byte holds one alphabetic character OR one or more numbers.  When we talk about memory and disk space, we use  Kilobytes -- 1,000 bytes  Megabytes -- 1 Million bytes  Gigabytes -- 1 Billion bytes  Terabytes -- 1 Trillion bytes  Let’s assume we have a computer with only 16 bytes of memory  Each square below represents 1 byte  Each square is assigned an address 0 1 2 S 3 T 4 E 5 V 6 E 7 N 8 9 10 11  The computer would input the first letter and put in address 2, input the 2nd letter and put it in address 3, etc  When it is time to print the name, we would have to remember the address used and refer to that address again in order to print the name.  That seems simple enough when the computer only has 16 addresses (bytes), but what about a million?  Instead, names can be assigned to an address, EX. (“”) o These names are variable names, which means they are easily changed.  When new data is moved to a location, old data is replaced.  Similarly, when calculations are done, the contents of the memory location (not the address) is used in the calculation. Bits, Bytes, and Nibbles  Bit = smallest unit o Stands for BInary digiT o Only has 2 values : 0 or 1  Nibble = 4 bits  Byte = 2 nibbles or 8 bits  Each memory location has: o An address = where it is o Contents = what’s in the address DATA STORAGE  Data Storage o For text characters such as names and part descriptions, it takes one byte to store one character. This type of data is often called string data o For text characters such as names and part descriptions, it takes one byte to store one character. This type of data is often called string data o Some number are actually stringdata such as an address (5983 Macon Cove). If a number is not used in a calculation, it will be stored as a string data  Special characters will also be string data  Software o Applications  Does “people” work  Examples: spreadsheets, word processors, airline, reservations, ATM’s  Created using HIGH-LEVEL languages, such as C. Visual Basic (VB), PERL o Systems  Does computer work  Example: operating systems (Windows, Linux/Unix, Mac OS)  Controls the input output devices  Creation of Software o To run on a computer, software must be in machine language o Refer to Creation of software in 1/24/17 powerpoint  So how do we get from high-level to machine level? o High level is easier for people o Machine level is the only way for the machine o Must be translated o There are two ways to translate:  Interpreters - one instruction at a time  Compilers - all converted, then run  Source  Object  Pseudo Code and Programming languages o Pseudocode - computer like statements the would not really run on a computer, but it outlines what the steps will need to be o Programming Languages - a language designed for humans to write computer code  Syntax - rules that the code must follow  Examples: C, COBOL, Visual Basic, PERL  NUMBERING SYSTEMS  Numbering Systems  Variables, Constants o Variables = data that changes o Constants = don’t change within the same program  Numeric Data o Used to do arithmetic  Hourly wage  GPA  Credit Hours  Age  String Data o Data that is not used in a calculation  Name  Address  Parts description o Any data not used in a calculation  Assigning values to variables o One of the main strengths of the computer is doing calculations quickly  Possible calculations  Add  Subtract  Multiply  Divide  Exponents ^  Formula example  avg = ((test1 + test2) / 2 * .60) + (labavg * .40)  The Decimal System o “Decimal” is the latin word for 10  Computers think in binary (not decimal) o Computers are made up of electrical circuits o On and Off  Off = 0  On = 1 o It’s easy for a computer to think as…  0 = no electricity  1 = electricity o Binary comes from the latin word Two  Counting in Binary o When we count in decimal  1, 2, 3, 4, 5, 6, 7, 8, 9 o In Binary, we do the same thing, only with fewer digits  1 (one), 1 0 (two), 1 1 (three) o Since there are so few valid digits in binary, look at binary in groups of four(one nibble) or eight (one byte)  15 is the maximum value of a nibble  255 is the value of a byte BINARY LED TO HEXADECIMAL  The hexadecimal system is used to make the binary system easy to interpret  Hexadecimal comes from the latin word for “Sixteen”  There are 16 digits in the hexadecimal system  The valid digits in hexadecimal are o 0 o 1 o 2 o 3 o 4 o 5 o 6 o 7 o 8 o 9 o A  10 o B  11 o C  12 o D  13 o E  14 o F  15  Any NIBBLE can hold 1 hexadecimal  Important concepts o Binary numbers are used to represent the circuits in a computer, with each binary digit representing one bit o Hexadecimal numbers are used to interpret the binary …. 4 bits at a time (one nibble) o To convert to and from binary, use powers of two o To convert to and from hexadecimal, use powers of sixteen o HEX is a common abbreviation for hexadecimal  You can convert binary to hexadecimal by converting one nibble at a time, and then combining the multiple nibbles to make each column of the hexadecimal ASCII & EBCDIC  Text is ALSO represented in memory with hexadecimal values;  Each text character requires one byte in memory o however , instead of being calculated, letters and special characters are assigned a hexadecimal value  Numbers as string data o Remember that numbers are NOT used in calculations are string data  STEPS TO SOLVE A PROBLEM o Analyze the problem  Identify the problem  Understand the problem o Design a program to solve the problem  Identify alternative ways to solve the problem  Select the best alternative  List the instructions, step-by-step and in order, that solve the problem o Code the program  Translate the instructions into a computer language code  Translate the computer language to machine language  Closer look at step 2 (design the program) o First, define the data  What is the output i want?  Print?  Display?  Files to be created?  What input is available?  Input by a user on the keyboard?  A data file, and if so, where is the data file located?  What variables will i need in order to:  Hold the input  Get the output  Use as working fields to get to the result o Listing variable names:  Data can be stored in variables via  Input statements  Assignment statements  Whenever you input data, you must specify the name of the variable where the data will be placed  Assignment statements are also called FORMULAS  Calculations can be put together in formulas that assign a value to the variable  grosspay= hours * rate  A variable name must always be on the left side  The calculation must always be on the right side  Formulas can include many arithmetic operations:  avg = ((test1 + test2) / 2 * .60) + (labavg * .40)  Develop the procedural logic o What are the logical steps I need to take to get the desired result? o What order must i take those steps? o Draw the flowchart and/or write the pseudocode o Desk check the logic by “playing computer”  Let’s consider a simple problem: calculating an employee’s pay  The steps needed to calculate the pay would be o 1. Multiply hours * rate giving gross o 2. Multiply gross * taxrate giving fedtax o 3. Multiply gross * SSrate giving SocSec o 4. Add up Health, Dental and Retire giving deducts o 5. Subtract fedtax, SocSec, and deducts from gross, giving NetPay on paycheck Flowcharts and Pseudocode  Procedural logic o The programmer’s job is to  Write steps  Write order  Flowcharting o A visual representation of procedural logic o Symbols are used to represent the TYPE of processing (input, output, process, etc) o Words inside the symbols identify the detail description of the step to be taken o Arrows are used to represent the ORDER of operations  Input and output get one arrow in and one arrow out o The computer cannot do two things in one program, however, it can run multiple programs at a time  Loops are the only arrows that will ever go the opposite direction of the order of the flowchart.

Show more Read less
Institution
University Of South Africa
Course
COS1511 - Introduction To Programming 1 (COS1511)










Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
University of South Africa
Course
COS1511 - Introduction To Programming 1 (COS1511)

Document information

Uploaded on
April 5, 2022
Number of pages
25
Written in
2021/2022
Type
Class notes
Professor(s)
Prof rodgers
Contains
Senior

Subjects

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
DoctorReinhad Chamberlain College Of Nursing
View profile
Follow You need to be logged in order to follow users or courses
Sold
2133
Member since
4 year
Number of followers
1728
Documents
6004
Last sold
1 day ago
TOP SELLER CENTER

Welcome All to this page. Here you will find ; ALL DOCUMENTS, PACKAGE DEALS, FLASHCARDS AND 100% REVISED & CORRECT STUDY MATERIALS GUARANTEED A+. NB: ALWAYS WRITE A GOOD REVIEW WHEN YOU FIND MY DOCUMENTS OF SUCCOUR TO YOU. ALSO, REFER YOUR COLLEGUES TO MY ACCOUNT. ( Refer 3 and get 1 free document). AM AVAILABLE TO SERVE YOU ANY TIME. WISHING YOU SUCCESS IN YOUR STUDIES. THANK YOU.

3.6

300 reviews

5
130
4
48
3
55
2
17
1
50

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions