Pt 1420 Unit 4

In: Computers and Technology

Submitted By mashon01
Words 384
Pages 2
Unit 4 Research 1: Using Global Variables
Advantages of using Global Variables * Global variable belongs to every function in the program. * Avoid passing frequently-used variables between several functions. * A global variable is accessible in every scope. * A global variable can potentially be modified from anywhere. * It can be accessed from any other files using extern.
Disadvantages of using Global Variables * Non-locality -- Source code is easiest to understand when the scope of its individual elements is limited. Global variables can be read or modified by any part of the program, making it difficult to remember or reason about every possible use. * Implicit coupling -- A program with many global variables often has tight couplings between some of those variables, and couplings between variables and functions. Grouping coupled items into cohesive units usually leads to better programs. * Concurrency issues -- if globals can be accessed by multiple threads of execution, synchronization is necessary (and too-often neglected). When dynamically linking modules with globals, the composed system might not be thread-safe even if the two independent modules tested in dozens of different contexts were safe. * Namespace pollution -- Global names are available everywhere. You may unknowingly end up using a global when you think you are using a local (by misspelling or forgetting to declare the local) or vice versa. Also, if you ever have to link together modules that have the same global variable names, if you are lucky, you will get linking errors. If you are unlucky, the linker will simply treat all uses of the same name as the same object. * Memory allocation issues -- Some environments have memory allocation schemes that make allocation of globals tricky. This is especially true in languages where "constructors" have…...

Similar Documents

Pt 1420 Unit 10 Homework

...Introduction to Programming Unit 10 Assignment 1 Short Answer 1. * Open the file – Opening the file creates a connection between the file and a program; this allows the program to read data from the file. * Process the file – Data is either read from the file or written to the file * Closing the file – The file must be closed when a program is finished using it. Closing the file disconnects the file from the program. 2. The file must be closed so the program will force any unsaved data in the buffer to be written to the file. 4. The file will not be erased, and any new data will be written at the end of the file’s current contents. 5. The program will create a new file. Algorithm Workbench 1. Declare OutputFile myFile Open myFile “my_name.dat” Write myFile “fatima” Close myFile 2. Declare InputFile myFile Declare String name1 Open myFile “my_name.dat” Read myFile name1 Close myFile Display ”Hello! My name is,” 3. Declare OutputFile numberList Declare Integer counter = 1 Open numberList “number_list.dat” For counter = 1 to 100 Write numberList, counter Next counter End For Close numberList 4. Declare InputFile number_list Declare Integer myNumber Open number_list ”number_list.dat" Display "Here are the numbers: " While NOT eof (number_list) Read numberList myNumber Display myNumber End While Close myName Programming Exercise Pg. 410 1.......

Words: 291 - Pages: 2

Pt 1420

...Assignment 6. A loop that has no way of stopping, and repeats until the program is interrupted. 7. A Do-While loop 8. A variable that is used to accumulate the total of a series of numbers. 9. A sentinel is a special value that marks the end of a list of items. 10. A sentinel value must be unique enough that it will not be mistaken as a regular value in the list. Algorithm 3. // Declare a counter variable. Declare Integer // Constant for the maximum value Constant Integer MAX_VALUE = 100 //Display the multiples of 10 from 0 through 100 For counter = 0 to MAX_VALUE Display counter End For   4. //Declare Integer number Declare an accumulator variable Declare Integer total = 0 Declare Integer counter For counter = 1 to 10 Display “Enter a number.” Input number Set total = total + number End For Display “The total is”, total 9. Declare Integer count For count < 50 Display “The count is “, count Set count = 1 To 50 End For 10. //Declare integer count While count   Research List three examples that show when a count-controlled loop is better than condition-controlled loop in programming? 1. It keeps a count of the number of times you want to use the program to input data 2. It only runs as many times as you have instructed the program to run 3. It will stop after the allotted time it has been instructed to 2.List three examples that show when a condition-controlled is better than......

Words: 297 - Pages: 2

Pt 1420

...1. Why is the CPU the most important component in a computer? The CPU stands for Central Processing Unit. It does all the processing for the entire system. Without it, your computer can't do anything. It has nothing to process information. It's just dead without it. 2. What number does a bit that is turned on represent? What number does a bit that is turned off represent? When a bit is turned on, it represents a "1". When it is turned off, it represents a "0". The exact value depends on where the bit is within the byte it is part of. In the binary number 0000 0001, the last bit is set to 1 and represents the number 1. 3. What would you call a device that works with binary data? Digital Data is data that is stored in binary, and a Digital Device is any device that works with binary data 4. What are the words that make up a high-level programming language called? The words that make up a high-level programming language are known as key words or reserved words. 5. What are the short words that are used in assembly language called? Mnemonic 6. What is the difference between a complier and an interpreter? A compiler translates code from a source language (e.g. C, C++, and Java) to a target language, which can then be executed by a (virtual or physical) machine. An interpreter reads code in an interpreted language (e.g. PHP, Perl, and Java Script) and directly executes the contained instructions. 7. What type of software controls the internal operations......

Words: 293 - Pages: 2

Pt 1420 Unit 2 Homework

...Unit 2 Homework Short Answer Pg. 71 (1-4) 1.) Work directly with and interview the customer. 2.) Pseudocode is an informal language that has no syntax rules, and is not meant to be compiled or executed. 3.) Input is received, some process is performed on the input, output is produced. 4.) User-friendly means that something is easy for anyone, regardless of their level of experience, to use. Algorithim Workbench Pg. 71 (1-2) 1.) Declare Height as Integer Display “ Enter Height “ Input “ Height “ 2.) Declare Color as String Display “ Enter Color” Input “ Color “ Please view Visio Attachments for flow charts Programming Exercises Pg. 72 (1&4) 1.) Sub Main() Console.WriteLine("Mark Gutierrez") Console.WriteLine("123 Bonehead Lane") Console.WriteLine("702-555-555") Console.WriteLine("NSA") Console.ReadLine() End Sub End Module 4.) Module Module1 Sub Main() Dim gtotal As Double Dim taxamount As Double Dim subtotal As Double Dim tax As Double = 0.06 Dim item1 As Double Dim item2 As Double Dim item3 As Double Dim item4 As Double Dim item5 As Double Console.WriteLine("enter item #1 price") item1 = Console.ReadLine() Console.WriteLine("enter item #2 price") item2 = Console.ReadLine() Console.WriteLine("enter item #3 price") item3 =......

Words: 270 - Pages: 2

Nt 1420 Unit 3 Answers

...Short Answers Unit 3 1. WHAT TWO THINGS MUST YOU NORMALLY SPECIFY IN A VARIABLE DECLARATION? The variable’s name The variable’s data type 2. WHAT VALUE IS STORED IN UNINITIALIZED VARIABLES? =0 Research Unit 3 1. WHAT IS REVERSE ENGINEERING? The process of taking a piece of software or hardware an analyzing its functions an information flow and then translating those processes. 2. WHAT ARE THE ADVANTAGES AND DISADVANTAGES TO USE REVERSE ENGINEERING TO DISCOVER THE LOGICS OF A SOFTWARE PROGRAM? Advantages- one can repair certain bugs, see how a program operates, and improve the operation of the program. Disadvantages- certain other bugs may be introduced during the process 3. FIND ANY ONE TOOL AVAILABLE TO PERFORM REVERSE ENGINEERING OF SOFTWARE PROGRAMS. LIST AT LEAST FIVE FEATURES OF THAT TOOL. GDB-GNU DEBUGGER  Allows taking a program and breaking it down to the assembly language level  Debug your programs  Examine your programs  Command line based tool which makes it easier to issue different parameters  Debug the kernel of any operating system UNIT 3: ALGORITHM WORKBENCH 3. SET B= (2 + A) SET A= (B + 4) SET B=( A/ 3.14) SET A= (8-B) 4. A. Set result = x + y 12 = 4 +8 B. Set result = z * 2 4 = 2 * 2 C. Set result = y / x 2 = 8 / 4 D. Set result = y – z 6 = 8 – 2 5. Dim cost1 As Double = 0 6. Dim cost1 As Integer = 0 7. Dim cost1 As Integer = 27 8. Total = 10 + 14 9. due......

Words: 257 - Pages: 2

Pt 1420

...PT 1420 Student Name:__________________ Introduction to Programming Winter 2014/2015 Instructor: Martin Remmele Unit 7 Homework Assignment Due by end of first break February 10, 2015 Learning Objectives and Outcomes NOTE: This section lists concepts and techniques to be understood from this unit. The actual assignment that you are to complete is found in the next section: “Assignment Requirements”. * Be able to Use pseudocode/flowcharts to represent repetition structures. * Be able to Create While, Do-While, and Do-Until conditional loops. * Be able to Describe the implications of an infinite loop. Assignment Requirements Complete the following exercises. An exercise that calls for an algorithm may be written in English as a series of steps. An exercise that calls for program statements may be written in a) the text’s pseudocode, b) your own preferred pseudocode notation or c) Visual Basic. (VB code can simply be typed into your Word document; it does not have to be created in the development environment.) The logic of the statements will be more important to the grade than the syntax. * Short Answer Review Questions 1-5, starting on page 213 (5 pts each) * Algorithm Workbench Review Questions 1, 2, 7, and 8, starting on page 213 (10 pts each) * Programming Exercises 1, 3, and 4, starting on page 214 (10 points each) Required Resources *...

Words: 310 - Pages: 2

En 1420 Unit 1 Assignment

...EN 1420 Unit 1 Assignment 1. When I first encountered the word argument I immediately thought of politics. Now, I think of a conversation between people of opposing views discussing their personal point of view. 2. Politics/ School classes/ competing companies via T.V. commercials 3. Traditional arguments can be described as someone who wants to convince their audience to side with them and accept their points of view. This is seen in presidential elections and public debates. Consensual argument is the emphasis of agreement. This type of argument is often seen in the classroom amongst peers. 4. Some of the conditions necessary for an argument to work best would be; an issue, an arguer, audience, common ground, a forum, and audience outcomes. 5. Conditions of a failing argument would be; no disagreement or reason to argue, risky r trivial issue, inability to establish common ground, and standoffs or fights resulting in negative outcomes. 6. Ethical Argument- Ways to rebuild the economy/ ways to better the path of our nation. Unethical Argument- New credit lines that incur debt/ Advertisements for plastic surgery. 7. The role of the audience has changed drastically in the world as we catapult into the digital age. So easily now people are able to reach new information (good and bad, true and false) by simply getting onto the internet and clicking around. 8. Four sources of arguable issues can be found in many places, but the......

Words: 254 - Pages: 2

Pt 1420 Unit 2 Assignment 1 Homework

...syntax rules, and is not meant to be compiled or executed. Instead, programmers use pseudocode to create models, or “mock-ups” of programs 3. Computer programs typically perform what three steps? 1. Input is received. 2. Some process is performed on the input. 3. Output is produced. 4. What does the term “user-friendly” mean? The term user-friendly is commonly used in the software business to describe programs that are easy to use. Algorithm Workbench 1. Design an algorithm that prompts the user to enter his or her height and stores the user’s input in a variable named height. Display “Enter height” Input height Display “This is your entered height: ” , hieght 2. Design an algorithm that prompts the user to enter his or her favorite color and stores the user’s input in a variable named color. Display “This is your favorite color: ”, color Input color Display “What is your favorite color: , color Programming Exercises 1. Personal Information Design a program that displays the following information: Your name Your address, with city, state, and ZIP Your telephone number Your college major 1. Display “Enter your full name” 2. Input FullName 3. Display ” Enter your street address” 4 .Input StreetAddress 5. Display “Enter your city, state and zip code” 6. Input CityStateZip 7. Display ” What is your telephone number” 8. Input phone 9. Display ” What is your College Major” 10. Input major 11. Display ” Your name is: “ , FullName 12. Display ” Your......

Words: 795 - Pages: 4

Pt 1420 Unit 5 Assignment

...provides only one alternative path of execution. The action is conditionally executed because it is performed only when a certain condition is true. 2. You need to test a condition and then execute one set of statements if the condition is true. If the condition is false, you need to execute a different set of statements. What structure will you use? I will use the “If” statement because it is a dual alternative decision structure. 3. If you need to a test the value of a variable and use that value to determine which statement or set of statements to execute, which structure would be the most straightforward to use? The case structure lets the value of a variable or an expression determine which path of execution the program will take. 4. Briefly describe how the AND operator works. The AND operator takes two Boolean expressions as operands and creates a compound Boolean expression that is True only when both sub-expressions are true. 5. Briefly describe how the OR operator works. The OR operator takes two Boolean expressions as operands and creates a compound Boolean expression that is true when either of the sub-expressions is true. The following is an example of an If-Then statement that uses the OR operator: 6. When determining whether a number is inside a range, which logical operator is it best to use? The AND operator would be the best to use to determine whether or not a number is within a given range. 7. What is a flag and how does it work? A......

Words: 957 - Pages: 4

Pt 1420

...Assignment and Calculations, page 43). Set creditsLeft = creditsTaken – creditsNeeded Terms should be switched Step 3: Write the exact output you would expect from the following line of code if the user of the program enters “Nolan Owens”. (Reference: Displaying Items, page 40 – 41). Display “The student’s name is “, studentName The student’s name is Nolan Owens Step 4: Write the exact output you would expect from the following line of code if the user of the program enters a name of Nolan Owens and they have taken 20 credits so far. (Reference: Displaying Items, page 40 – 41). Display “The Network Systems Administration degree is awarded after 90 credits and “, studentName, “has “, creditsLeft, “left to take before graduation.” The Network Systems Administration degree is awarded after 90 credits and Nolan Owens has 70 left to take before graduation. Step 5: Complete the following pseudocode to solve the programming problem. 1. //Provide documentation on line 2 of what this program does 2. //Calculates credits needed to graduate 3. //Declare variables on lines 4, 5, 6, and 7 4. Declare Real creditsTaken 5. Declare Real creditsLeft 6. Declare String studentName 7. Constant Real CREDITS_NEEDED = 90 8. //Ask for user input of studentName and creditsTaken //on line 9 - 12. 9. Display “What is your name?” 10. Input studentName 11. Display “How many credits do you have?” 12. Input creditsTaken 13. //Calculate remaining......

Words: 603 - Pages: 3

Nt 1420 Unit 4

...switch port create one electrical circuit to use when sending data. The sender creates a (maximum) 1-volt electrical signal with a frequency of 1000 hertz. Which of the following facts are also true? (Choose two answers.) a. The period is 1/1000 of a second b. The phase changes over time. c. The amplitude changes over time. d. The amplitude is 1 volt. 3. A PC NIC and a switch port create one electrical circuit to use when sending data from the PC to the switch. Which of the following tasks is a function done by the transmitter? (Choose two answers.) a. Completes the electrical circuit by looping two wires together on its end b. Senses current on the circuit c. Creates current on the circuit d. Removes noise from the circuit 4. A PC NIC and a switch port create one electrical circuit to use when sending data from the PC to the switch. The transmitter uses a simple encoding scheme that uses a higher amplitude to encode 1 and a lower amplitude to encode 0, sending 1 bit in each bit time. The bit rate is 2000bits per second (2000 bps). Which of the following is true on this circuit? a. The bit time is .001seconds. b. The bit time is .0002 seconds. c. The transmitter must change the amplitude 2000times per second. d. The transmitter can change the amplitude 2000 times per second. 5. Two nodes use an encoding scheme that cannot use one circuit to both send and receive data at the same time. The link physically contains two wires. Which of the following......

Words: 1501 - Pages: 7

Pt 1420 Midterm

...Mnemonics Name a high level language you use in the course. Visual Basic  The words that make up a high level programming language are know as what? Keywords  When a CPU executes instructions in a program, it is known as what? The Fetch-Decode-Execute Cycle  Which runs faster a compiled or an interpreted program? Compiled  Which language utilizes binary numbers like 01110000? Machine Language  Which language utilizes commands like ADD A7? Assembly Language  What is the method used to store negative integers into memory? Two's Compliment  How many steps are in the Program Development Cycle and what are they? 1 - Design the Program 2 - Write the Code 3 - Correct Syntax Errors 4 - Test the Executable Code 5 - Debug the Code  What is an informal language that has no syntax rules and is not meant to be compiled or executed? Pseudo Code  What is a diagram that graphically depicts the steps that take place in a program? Flowchart  What is a set of statements that execute in the order that they appear? Sequence Structure  What is a logical design that controls the order in which a set of statements execute? Control Structure  What graphically displays boxes that represent each module in a program? Hierarchy Chart  Which flowchart symbol represents processing and is used with the keywords Set and Declare? Rectangle  Which flowchart symbol represents a......

Words: 1275 - Pages: 6

Pt 1420 Homework

...Pt 1420 Unit 10 Homework Introduction to Programming Unit 10 Assignment 1 Short Answer 1. * Open the file – Opening the file creates a connection between the file and a program; this allows the program to read data from the file. * Process the file – Data is either read from the file or written to the file * Closing the file – The file must be closed when a program is finished using it. Closing the file disconnects the file from the program. 2. The file must be closed so the program will force any unsaved data in the buffer to be written to the file. 4. The file will not be erased, and any new data will be written at the end of the file’s current contents. 5. The program will create a new file. Algorithm Workbench 1. Declare OutputFile myFile Open myFile “my_name.dat” Write myFile “fatima” Close myFile 2. Declare InputFile myFile Declare String name1 Open myFile “my_name.dat” Read myFile name1 Close myFile Display ”Hello! My name is,” 3. Declare OutputFile numberList Declare Integer counter = 1 Open numberList “number_list.dat” For counter = 1 to 100 Write numberList, counter Next counter End For Close numberList 4. Declare InputFile number_list Declare Integer myNumber Open number_list ”number_list.dat" Display "Here are the numbers: " While NOT eof (number_list) Read numberList myNumber Display myNumber End While Close myName Programming Exercise Pg. 410 1. Declare Integer number......

Words: 296 - Pages: 2

Pt 1420 Unit 5-1

...expression determine which path of execution the program will take. 4. The AND operator takes two Boolean expressions as operands and creates a compound Boolean expression that is True only when both sub-expressions are true. 5. The OR operator takes two Boolean expressions as operands and creates a compound Boolean expression that is true when either of the sub-expressions is true. The following is an example of an If-Then statement that uses the OR operator: 6. The AND operator would be the best to use to determine whether or not a number is within a given range. 7. A flag is a Boolean variable that signals when some condition exists in the program. When the flag is set to False, it indicates the condition does not exist. When the flag variable is set to True, it means the condition does exist. Algorithm Workbench 1. Y=20 Z=40 End If 2. B=0 C=1 End If 3. B=0 Else B=99 End if 4. If score < 60 Then Display “Your grade is F” Else If score < 70 Then Display “Your grade is D” Else If score < 80 Then 5. If amount1 > 10 and amount2 < 100 Then If amount1 > amount2 Then Display “amount1 is > amount2 ”Else If amount1 < amount2 Then Display “amount2 is greater then amount1” End If Programming exercises 1. If variable is set to 1, then display “I” If variable is set to 2, then display “II” If variable is set to 3. then display ”III” If variable is set to 4, then display “IV” If variable is set to 5, then display “V” If......

Words: 401 - Pages: 2

Fires of Jubilee Pt 4

...Antwan Rowel Mr.Kimbrough History B20a MW 9:35 November 7, 2011 Fires of Jubilee Pt.4 In The Fires of Jubilee Nat Turner's Fierce Rebellion: Stephen Oates gives an account of the brief but deadly slave revolt in and around Southampton, Virginia. His controlling theme is that of religion and the profound influence that it had on the development of Nat Turner's charismatic persona and his rationale for engaging in a project of deliberate murder of people who had at least in the context of slavery as a given of Turner's experience, treated him quite decently. The effects of Nat Turner's rebellion were profound. The insurrection of Nat Turner was inspiration for all slaves, even if just 60 whites were killed to the 140 blacks. I am impressed by his courage. The attitudes of many plantation owners changed as a result of Nat. Many people had believed that slaves would never think of hurting their "loving, Christian" master. What Nat did scared many whites tremendously. The Virginia state legislature actually debated freeing all slaves to avoid future conflict. Of course this never happened but this was the first time that such an idea had ever been discussed. Many slave holders blamed the rebellion on the abolishment movement. The same year of Nat's rebellion, William Lloyd Garrison began publishing "The Liberator". Some people attributed this to the cause of the killings. Laws were passed that forbid teaching slaves to read or write. An educated slave could be a dangerous......

Words: 593 - Pages: 3