CS 142 Style Guide Grading and Details
|
|
- Sabina Paul
- 5 years ago
- Views:
Transcription
1 CS 142 Style Guide Grading and Details In the English language, there are many different ways to convey a message or idea: some ways are acceptable, whereas others are not. Similarly, there are acceptable and unacceptable methods for coding. In order to help you establish good coding practices we have created a style guide. Most companies have a coding style guide that all programmers follow in order to make it easier to understand and adapt code. We do the same for this class and expect everyone to follow the style guide. This makes it so that TAs know how to grade your style and you know what to expect. Get in the habit of using correct style when you first start writing code, rather than going back later to fix it up. You should be proud of how your code looks! Grading: It is possible that your text or instructor may use a style different than the ones described in the style guide, but your grading will be based on the style guide. Each main lab (or exam) can receive up to 100 auto-grade points based on your zybook submission. After you request grading, a TA grades your submission for adherence to 1) the style guide, and 2) any special requirements outlined in the lab specification. Special requirements are there to help you learn the key goals of the lab. They are graded all or nothing (unless stated otherwise), in that you lose all the requirement points if you do not comply. For each lab, there is a 3 point deduction for the first infraction of a style. There is a 1 point deduction for each subsequent infraction of that style up to a maximum of 6 points per style. The maximum points you can lose for style infractions is listed in each specification and is usually 20 points. To help you see our goal with this point system, consider the style indentation. If you did bad indentation 20 times in your program, we would not want you to lose all 20 points based on that one style error. We want to take off enough for the first incident (3 points) to get your attention so you will improve next time, and take off some points for repeated mistakes. In this case you would lose 3 points for the first infraction, and 1 point each for the next three with a maximum deduction of 6 for that style. The TAs will correct all style infractions in your code, so that you can learn and improve, even though you may have already exceeded the style deduction maximum. In the case of the descriptive names style, the infraction comes when you declare the variable. If you declare a variable with name "x" you will have 3 points deducted for bad naming, but not get another point off for each time that same variable "x" appears in your code. If you have another poorly named variable (e.g. "y") you will have another point deducted for its declaration, up to 6 points. Similarly, if you had the same magic number 371 appear multiple times in your program, rather than an appropriate constant, you would lose 3 points. If you had a different magic number (e.g. 13 occur multiple times), you would lose another point for that. You lose points for multiple infractions in the same line of code. If you declared a constant named zx, you would lose 3 points for bad naming, and also 3 points because constants must be all caps. Note that Self-Documenting Code has subcategories, so you could lose up to 6 points for each. Assume a lab has 3 special requirements each with a deduction of 10 points. Assume you received all 100 points for auto-grade, missed 12 style points, and you did not follow one of the special requirements. Your score would be 78. The TA then adds early points. If the lab is late by less than your remaining late days, the TA subtracts the number of late days from your total late day reserve. If the late days exceed your total, the lab will not be graded and you will receive a 0. TAs give clear feedback on points deducted, specifying where errors occurred, and give any other commentary needed to help you learn and do better the next time. You can view feedback from the TA in the feedback box for the assignment in learning suite. The feedback identifies which TA graded in case you have questions.
2 Variable Naming: How you name your variables is crucial to code readability. A good question to ask when naming a variable is, "If someone else saw this variable name, would they immediately know what it is used for?" Variable names must describe what they are used for, not describe the value they hold, since that value can change. Test Cases: The goal of test cases is to do our best to ensure code is working properly. We test for simple situations and also for less common cases. When testing a video game, testers do not simply play the game through; instead, they do obscure things such as walk into walls and corners, jump up trees, and cross invisible boundaries. Their goal is to do what we call break the code. They want to find all possible errors in the game, expose them, and then fix them. When you test your code, you want to consider where your code could fail, and then test your program such that you are testing the possible problem areas. You will include 3 example test cases for main labs (except where specifically noted). Three test cases are not enough to check all combinations. However, we consider the test cases you include as examples and evidence of your more thorough testing which you did above and beyond your three examples. Therefore, we expect your test cases to be diverse, attempting to test and explore different issues. If you do not include test cases you receive 3 points off for the first and 1 each for the others for a 5 point deduction. Your test cases must be your own. If you use a test case from the specification, or any of the visible test cases of the zybook auto-grader, you will be graded as if you had not written that test case. A key is that you should write test cases, including the output worked out by hand, BEFORE coding. One of the most helpful things about writing and solving a test case before coding is that it gives you the chance to think about the steps you have to take (as a human) to produce the correct output. If you do not understand the steps you must follow in order to generate correct output, it will be impossible to write a program to do so. If you create test cases after your program is done and just plug in the answers your code gives, you not only lose the comprehension benefits of test cases, but you do not even test if your code gives correct answers! On exams, we usually have you write at least one test case for your problem. Some students complain because even though they didn't completely finish the exam question, they still lost style points for not having a test case, which they planned on coming back and putting in after they got the program done. That is backwards! If they had done their test case first, they would have better understood the question, and perhaps got it working, and also received the style points. Following is an example of test cases. In the Pizza lab you will test with inputs that test different combinations such as just one of each type of pizza, all types of pizza, different sizes of tips, etc. For example on the Pizza lab you might first try with 1, 3, and 7 guests to test the one pizza each variations. Then, maybe test for one large pizza and one medium. Did that check out? If so, then test for one large, one medium, and one small. If that checks out, you move on to larger cases. The three test cases chosen from your more comprehensive testing reflect this effort. The Pizza lab does not ask you to test for incorrect input. Most labs will ask for that, and part of your testing must test to make sure your program handles "bad" inputs. In the first couple of labs you could actually just show the exact expected output that your program should give. However, this would get annoying as the full textual output for later programs could be very long and you really just want to focus on whether your program is getting the key calculated values right. In these cases, you do not need to write down all the formatted output text and you can focus on the information calculated and manipulated by the program. You can format your test cases however you would like as long as they are clear and easy to read, and clearly specify the inputs and expected output values. In the pizza lab one might show the following three test cases. (Do not use these exact cases as your examples).
3 /* Test 1: Input: (11, 10) Expected output: (1, 1, 1, , ,37) Result: Passed Test 2: Input: (4, 0) Expected output: (0, 1, 1, , , 19) Result: 1, 1, 1, 444,234, This led me to fix a bug where I had a wrong sign in my area equation Test 3: Input: (452, 15) Expected output: (64, 1, 1, , , 1102) Result: Passed */ Another resource to help you understand good test cases is to look at the test cases your code is tested with in the zybooks auto-grader. We use test cases to see if your code works and you could pattern some of your test cases after these. But come up with your own. Notice that our test cases try a variety of bad input and input which is intended to test what might be unusual cases (for example, places where you might have used ">" where you should have used ">="). In most cases it is impossible to test all possible inputs, so that is not what we are looking for, but rather that you are making an honest attempt to validate your code. One more test case example: Read this part once you get to the Plinko lab. Many wonder how to do tests with the Plinko lab where there are many more possibilities and there is also a random aspect to dropping a chip. Here is an approach I might use if I were in your place. I would want one test case that tested the possible types of input errors to ensure there is an appropriate re-request when an input error is made. Test Case #1 Input: The following test case is a stream of inputs which tests the possible erroneous input situations: -1, 4, 1, -3, 9, 4, 2,. (you fill in the rest) Expected output: Verify that an appropriate error message is given for each input error and that there is an appropriate re-request until a correct input is given. This communicates the full goal of this test case without having to show the long textual output which will actually be output. For the next two test cases I would want to make sure that I was getting correct outputs for drop one and drop multiple chips (in these cases not worrying about erroneous input which was tested in the first test case). With rand() we can set a fixed seed during testing so we know beforehand exactly what the random sequence will be. One approach is to write a separate tiny program, seed rand with a fixed value, and run a loop giving the first n (left, right) choices. Then I know exactly which direction will be chosen at each step. Then I could test what should happen when I drop a chip in any slot. Note that I try a drop in the middle but also one at each edge to make sure I am handling border cases. Test Case #2: Input: (using fixed seed of x) 1, 4, 1, 8, 1, 0, 0 Expected output: [ ] Winnings: $0.00 [ ] Winnings: $ [ ] Winnings: $ Test Case #3:
4 Input: (using fixed seed of x) 2, 2, 4, 0 Expected output: Total winnings: $ Average winnings per chip: $ Magic Numbers: Literal numbers other than 0, 1, and -1 should rarely occur in the body of your code. Use constants or variables to replace magic numbers. Using constants has two important advantages. First, they make the code easier to read. Your code should read more like English prose with numbers replaced by descriptively named constants. Second, in cases where the programmer wants to later change the value of a constant, it need only be changed in one place at the declaration, and it will be updated in all places throughout the program. For example, you must never have a line of code in you program like: labgrade = labgrade + 4; In this case 4 is a magic number, where someone reading the code might not know what the 4 represents. Rather, you would declare and initialize a const variable at the top of your function and then later use it in your code. const int EARLY_HAND_IN_BONUS = 4; labgrade = labgrade + EARLY_HAND_IN_BONUS; To make grading, the only situations we will grade are for numeric values given in the assignment specification. For example, if a specification said that one large pizza serves 7, and the price of a large pizza is $13.98, then you must have two constants like the following used in your program. const int PEOPLE_SERVED_PER_LARGE_PIZZA = 7; const double PRICE_OF_LARGE_PIZZA = 13.98; We now give good practice for when "magic numbers" must be replaced by constants, but only the above cases will be graded. Just because a literal is 0 or 1 does not mean it should never be a constant. In fact, in cases except for those below, a 0 and 1 should usually be a constant. For example, in main lab #2 (Pizza) the spec states that a large pizza feeds 7, a medium 3, and a small 1. 7 and 3 are obvious magic numbers. But so is 1 in this case, both because the meaning of 1 in the coding context may not be obvious, and we may want to later change the number of people that a small pizza feeds. Times when 0, 1, and -1 are not magic numbers are: 1. Initializing variables 2. Resetting a counter 3. Incrementing or decrementing (though it is preferred you use ++ and --) 4. Simple boundary and index adjustment: for (int i = 0; i < str.size() 1; i++) 5. return 0 at the end of main The major exception for arbitrary numbers to not be constants are in common mathematical equations or arithmetic manipulations such as circumference = 2 * PI * radius; In this case you would be hard pressed to even think of a good name to replace the 2, and if you did it would probably make the formula less readable. Also, since it is a mathematical axiom, we would not be changing the value in the future, thus we would gain neither of the advantages of using constants.
5 Be careful NOT to use constants inappropriately as you will lose points if you do. Two common mistakes beginning students make are: 1. const int ZERO = 0; This does nothing of use. It does not make the code more readable (0 and ZERO are equivalent) and it does not make things more adaptable. You would never want to later set ZERO = const int FIVE_YEAR_LOAN_LIFE = 5; In this case the variable cannot be changed to another value (e.g. 10) without needing to change the name of the variable. Instead, name it something like LIFE_OF_LOAN, which is both descriptive AND can be changed later without needing to change the name. Thus never use the value of the constant as part of the name of a constant. One could argue that these cases better fall under variable naming, but since they happen most frequently with constants replacing magic numbers, we include it for both discussion and grading under magic numbers. Suggested Style Practices The style guide for companies is usually long and detailed. We previously used a longer style guide in 142, but decided to use a short version to let you learn and experience style without it becoming overbearing. Following are some of the styles which we used to grade. We suggest you follow these, but will not grade them. They improve code readability and decrease bugs. Initialize variables when they are declared. By initializing numbers to a consistent initial value (e.g. 0), you avoid difficult bugs when your code is mistakenly using an uninitialized variable that contains an unpredictable random value, giving unpredictable bugs. Some types, like strings, are automatically initialized. Integers, reals (double, float), Booleans, and characters should be initialized at the time of their declaration. Default values are 0, 0.0, false, and null (\0) respectively, if not initialized to a program specific value. int main() { const double ROCKET_SPEED = ; int planetsvisited = 0; bool arewethereyet = false; // You could use 0 or false here double distancefromsun = 0.0; char currentquadrant = '\0'; Whitespace: While the compiler ignores whitespace, how you use it greatly affects readability. To improve readability, the following spacing rules are suggested. 1. Each statement should appear on its own line. 2. Most items are separated by exactly one space, though there are common exceptions which you will see as you study more code. Common guidelines are: a. All binary operators (+. -. =, >>, etc.) have one preceding and following space b. No space precedes an ending semicolon c. No space follows a "(" or precedes a ")" 3. Lines of code are less than 120 characters; if necessary continue on a newline with an indent. 4. Leave a blank line between distinct sections of code. Functions: Functions should do one task. For example, you would not want a function that both a) returns the total number of words in a document and b) capitalizes first letters of all the words. Those should be done by separate functions, making them simpler and more general to use and adapt in the future. Functions should be kept short as possible, making them more readable and easier to write. Functions are structured to avoid duplication of code. You should not have places in your code where you have snippets of the same code many times, which is better handled by a function call each time. With void functions, return can be used for returning early in the function, but unlike non-void functions, it is optional whether you put a "return" at the end.
6 Miscellaneous: Following are other suggested guidelines: Do not use global variables, except for constants which are used in multiple functions int main() must end with return 0; Never use the C++ command "goto" Use endl rather than "\n" where possible For Classes: o Always create your own default constructor for each class, and create a parameterized constructor(s) when needed (usually). You may combine these into one constructor function by creating a default constructor with default parameters. o Any member function that will not mutate data members should be declared as const. o All data members and helper functions should be private (or protected). Conclusion: We will not take off points for style decisions a student makes for situations not specified in the style guide. We cannot mention all possible bad style decisions one might make (see Mosiah 4:29,30). If a TA sees that you did something inappropriate, they will help you by pointing it out, but not taking off points.
CS 142 Style Guide CAREFULLY READ THIS GUIDE; THESE ITEMS ARE WORTH A SIGNIFICANT PORTION OF YOUR LAB AND EXAM GRADES.
CS 142 Style Guide CAREFULLY READ THIS GUIDE; THESE ITEMS ARE WORTH A SIGNIFICANT PORTION OF YOUR LAB AND EXAM GRADES. How the guide works: In the English language, there are many different ways to convey
More informationMakefiles Makefiles should begin with a comment section of the following form and with the following information filled in:
CS 215 Fundamentals of Programming II C++ Programming Style Guideline Most of a programmer's efforts are aimed at the development of correct and efficient programs. But the readability of programs is also
More informationACORN.COM CS 1110 SPRING 2012: ASSIGNMENT A1
ACORN.COM CS 1110 SPRING 2012: ASSIGNMENT A1 Due to CMS by Tuesday, February 14. Social networking has caused a return of the dot-com madness. You want in on the easy money, so you have decided to make
More informationBASIC ELEMENTS OF A COMPUTER PROGRAM
BASIC ELEMENTS OF A COMPUTER PROGRAM CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING LOGO Contents 1 Identifier 2 3 Rules for naming and declaring data variables Basic data types 4 Arithmetic operators
More informationControl Structures. Lecture 4 COP 3014 Fall September 18, 2017
Control Structures Lecture 4 COP 3014 Fall 2017 September 18, 2017 Control Flow Control flow refers to the specification of the order in which the individual statements, instructions or function calls
More informationC++ Style Guide. 1.0 General. 2.0 Visual Layout. 3.0 Indentation and Whitespace
C++ Style Guide 1.0 General The purpose of the style guide is not to restrict your programming, but rather to establish a consistent format for your programs. This will help you debug and maintain your
More informationQUIZ: What value is stored in a after this
QUIZ: What value is stored in a after this statement is executed? Why? a = 23/7; QUIZ evaluates to 16. Lesson 4 Statements, Expressions, Operators Statement = complete instruction that directs the computer
More informationCS102: Variables and Expressions
CS102: Variables and Expressions The topic of variables is one of the most important in C or any other high-level programming language. We will start with a simple example: int x; printf("the value of
More informationTips from the experts: How to waste a lot of time on this assignment
Com S 227 Spring 2018 Assignment 1 100 points Due Date: Friday, September 14, 11:59 pm (midnight) Late deadline (25% penalty): Monday, September 17, 11:59 pm General information This assignment is to be
More informationChapter 2 Basic Elements of C++
C++ Programming: From Problem Analysis to Program Design, Fifth Edition 2-1 Chapter 2 Basic Elements of C++ At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion
More information2 nd Week Lecture Notes
2 nd Week Lecture Notes Scope of variables All the variables that we intend to use in a program must have been declared with its type specifier in an earlier point in the code, like we did in the previous
More informationLecture 4 CSE July 1992
Lecture 4 CSE 110 6 July 1992 1 More Operators C has many operators. Some of them, like +, are binary, which means that they require two operands, as in 4 + 5. Others are unary, which means they require
More informationCS 1044 Project 1 Fall 2011
Simple Arithmetic Calculations, Using Standard Functions One of the first things you will learn about C++ is how to perform numerical computations. In this project, you are given an incomplete program
More informationMARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #2 Examination 12:30 noon, Thursday, March 15, 2012
MARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #2 Examination 12:30 noon, Thursday, March 15, 2012 Instructor: K. S. Booth Time: 70 minutes (one hour ten minutes)
More informationChapter 2. C++ Basics. Copyright 2014 Pearson Addison-Wesley. All rights reserved.
Chapter 2 C++ Basics Overview 2.1 Variables and Assignments 2.2 Input and Output 2.3 Data Types and Expressions 2.4 Simple Flow of Control 2.5 Program Style 3 2.1 Variables and Assignments Variables and
More informationChapter 2. C++ Basics
Chapter 2 C++ Basics Overview 2.1 Variables and Assignments 2.2 Input and Output 2.3 Data Types and Expressions 2.4 Simple Flow of Control 2.5 Program Style Slide 2-2 2.1 Variables and Assignments Variables
More informationCS 251 Intermediate Programming Methods and Classes
CS 251 Intermediate Programming Methods and Classes Brooke Chenoweth University of New Mexico Fall 2018 Methods An operation that can be performed on an object Has return type and parameters Method with
More informationFull file at
Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class
More informationObjectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program
Objectives Chapter 2: Basic Elements of C++ In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates
More informationChapter 2. C++ Basics. Copyright 2014 Pearson Addison-Wesley. All rights reserved.
Chapter 2 C++ Basics 1 Overview 2.1 Variables and Assignments 2.2 Input and Output 2.3 Data Types and Expressions 2.4 Simple Flow of Control 2.5 Program Style Slide 2-3 2.1 Variables and Assignments 2
More informationChapter 2: Basic Elements of C++
Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates
More informationChapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction
Chapter 2: Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 1 Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers
More informationAbsolute C++ Walter Savitch
Absolute C++ sixth edition Walter Savitch Global edition This page intentionally left blank Absolute C++, Global Edition Cover Title Page Copyright Page Preface Acknowledgments Brief Contents Contents
More informationCom S 227 Spring 2018 Assignment points Due Date: Thursday, September 27, 11:59 pm (midnight) "Late" deadline: Friday, September 28, 11:59 pm
Com S 227 Spring 2018 Assignment 2 200 points Due Date: Thursday, September 27, 11:59 pm (midnight) "Late" deadline: Friday, September 28, 11:59 pm (Remember that Exam 1 is MONDAY, October 1.) General
More informationComputer Programming : C++
The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2003 Muath i.alnabris Computer Programming : C++ Experiment #1 Basics Contents Structure of a program
More informationDecision Logic: if, if else, switch, Boolean conditions and variables
CS 1044 roject 4 Summer I 2007 Decision Logic: if, if else, switch, Boolean conditions and variables This programming assignment uses many of the ideas presented in sections 3 through 5 of the course notes,
More informationgcc o driver std=c99 -Wall driver.c bigmesa.c
C Programming Simple Array Processing This assignment consists of two parts. The first part focuses on array read accesses and computational logic. The second part focuses on array read/write access and
More informationThe Program Specification:
Reading to Input Failure, Decisions, Functions This programming assignment uses many of the ideas presented in sections 3 through 8 of the course notes, so you are advised to read those notes carefully
More informationCPS122 Lecture: From Python to Java last revised January 4, Objectives:
Objectives: CPS122 Lecture: From Python to Java last revised January 4, 2017 1. To introduce the notion of a compiled language 2. To introduce the notions of data type and a statically typed language 3.
More informationCpSc 1111 Lab 6 Conditional Statements, Loops, the Math Library, and Random Numbers What s the Point?
CpSc 1111 Lab 6 Conditional Statements, Loops, the Math Library, and Random Numbers What s the Point? Overview For this lab, you will use: one or more of the conditional statements explained below scanf()
More informationCIS220 In Class/Lab 1: Due Sunday night at midnight. Submit all files through Canvas (25 pts)
CIS220 In Class/Lab 1: Due Sunday night at midnight. Submit all files through Canvas (25 pts) Problem 0: Install Eclipse + CDT (or, as an alternative, Netbeans). Follow the instructions on my web site.
More informationCS 251 Intermediate Programming Methods and More
CS 251 Intermediate Programming Methods and More Brooke Chenoweth University of New Mexico Spring 2018 Methods An operation that can be performed on an object Has return type and parameters Method with
More informationChapter Overview. C++ Basics. Variables and Assignments. Variables and Assignments. Keywords. Identifiers. 2.1 Variables and Assignments
Chapter 2 C++ Basics Overview 2.1 Variables and Assignments 2.2 Input and Output 2.3 Data Types and Expressions 2.4 Simple Flow of Control 2.5 Program Style Copyright 2011 Pearson Addison-Wesley. All rights
More informationProblem Solving with C++
GLOBAL EDITION Problem Solving with C++ NINTH EDITION Walter Savitch Kendrick Mock Ninth Edition PROBLEM SOLVING with C++ Problem Solving with C++, Global Edition Cover Title Copyright Contents Chapter
More informationIntroduction to Computers and C++ Programming p. 1 Computer Systems p. 2 Hardware p. 2 Software p. 7 High-Level Languages p. 8 Compilers p.
Introduction to Computers and C++ Programming p. 1 Computer Systems p. 2 Hardware p. 2 Software p. 7 High-Level Languages p. 8 Compilers p. 9 Self-Test Exercises p. 11 History Note p. 12 Programming and
More informationVariables and Operators 2/20/01 Lecture #
Variables and Operators 2/20/01 Lecture #6 16.070 Variables, their characteristics and their uses Operators, their characteristics and their uses Fesq, 2/20/01 1 16.070 Variables Variables enable you to
More informationLaboratory 2: Programming Basics and Variables. Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information
Laboratory 2: Programming Basics and Variables Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information 3. Comment: a. name your program with extension.c b. use o option to specify
More informationCoding Standard for ECE3090 August 24, 2005
Coding Standard for ECE3090 August 24, 2005 1 Introduction This document describes the coding standard to be used by all program submissions for ECE3090. Consistency of coding style for all students leads
More informationCpSc 1111 Lab 4 Part a Flow Control, Branching, and Formatting
CpSc 1111 Lab 4 Part a Flow Control, Branching, and Formatting Your factors.c and multtable.c files are due by Wednesday, 11:59 pm, to be submitted on the SoC handin page at http://handin.cs.clemson.edu.
More informationLESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are:
LESSON 1 FUNDAMENTALS OF C The purpose of this lesson is to explain the fundamental elements of the C programming language. C like other languages has all alphabet and rules for putting together words
More informationCSE 11 Style Guidelines
CSE 11 Style Guidelines These style guidelines are based off of Google s Java Style Guide and Oracle s Javadoc Guide. Overview: Your style will be graded on the following items: File Headers Class Headers
More informationBASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I
BASIC COMPUTATION x public static void main(string [] args) Fundamentals of Computer Science I Outline Using Eclipse Data Types Variables Primitive and Class Data Types Expressions Declaration Assignment
More informationThese are notes for the third lecture; if statements and loops.
These are notes for the third lecture; if statements and loops. 1 Yeah, this is going to be the second slide in a lot of lectures. 2 - Dominant language for desktop application development - Most modern
More information3. Simple Types, Variables, and Constants
3. Simple Types, Variables, and Constants This section of the lectures will look at simple containers in which you can storing single values in the programming language C++. You might find it interesting
More informationSTUDENT OUTLINE. Lesson 8: Structured Programming, Control Structures, if-else Statements, Pseudocode
STUDENT OUTLINE Lesson 8: Structured Programming, Control Structures, if- Statements, Pseudocode INTRODUCTION: This lesson is the first of four covering the standard control structures of a high-level
More informationComputer Science C++ Placement Exam
Computer Science C++ Placement Exam The Computer Science Department now has available a placement exam for students who wish to demonstrate their competence in the material covered in the course CSCI C101
More informationCOMP 202 Java in one week
COMP 202 Java in one week... Continued CONTENTS: Return to material from previous lecture At-home programming exercises Please Do Ask Questions It's perfectly normal not to understand everything Most of
More informationIntroduction to the C++ Programming Language
LESSON SET 2 Introduction to the C++ Programming Language OBJECTIVES FOR STUDENT Lesson 2A: 1. To learn the basic components of a C++ program 2. To gain a basic knowledge of how memory is used in programming
More informationLecture 04 FUNCTIONS AND ARRAYS
Lecture 04 FUNCTIONS AND ARRAYS 1 Motivations Divide hug tasks to blocks: divide programs up into sets of cooperating functions. Define new functions with function calls and parameter passing. Use functions
More informationVariables. Data Types.
Variables. Data Types. The usefulness of the "Hello World" programs shown in the previous section is quite questionable. We had to write several lines of code, compile them, and then execute the resulting
More informationFormatting & Style Examples
Formatting & Style Examples The code in the box on the right side is a program that shows an example of the desired formatting that is expected in this class. The boxes on the left side show variations
More informationTOPIC 2 INTRODUCTION TO JAVA AND DR JAVA
1 TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B. Ericson, and instructor materials prepared
More information2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program
Chapter 2: Introduction to C++ 2.1 Parts of a C++ Program Copyright 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Parts of a C++ Program Parts of a C++ Program // sample C++ program
More informationC++ Basics. Data Processing Course, I. Hrivnacova, IPN Orsay
C++ Basics Data Processing Course, I. Hrivnacova, IPN Orsay The First Program Comments Function main() Input and Output Namespaces Variables Fundamental Types Operators Control constructs 1 C++ Programming
More informationCSCI 262 C++ Style Guide
CSCI 262 C++ Style Guide Christopher Painter-Wakefield and Mark Baldwin and Alex Anderson Last updated: 1/18/2018 Modified from: C++ Student Coding Standards Mark Baldwin Version 1.02 5/21/2013 2012 Mark
More informationFundamentals of Programming CS-110. Lecture 2
Fundamentals of Programming CS-110 Lecture 2 Last Lab // Example program #include using namespace std; int main() { cout
More informationLab Exercise 6: Abstract Classes and Interfaces CS 2334
Lab Exercise 6: Abstract Classes and Interfaces CS 2334 September 29, 2016 Introduction In this lab, you will experiment with using inheritance in Java through the use of abstract classes and interfaces.
More informationCpSc 1011 Lab 5 Conditional Statements, Loops, ASCII code, and Redirecting Input Characters and Hurricanes
CpSc 1011 Lab 5 Conditional Statements, Loops, ASCII code, and Redirecting Input Characters and Hurricanes Overview For this lab, you will use: one or more of the conditional statements explained below
More information1007 Imperative Programming Part II
Agenda 1007 Imperative Programming Part II We ve seen the basic ideas of sequence, iteration and selection. Now let s look at what else we need to start writing useful programs. Details now start to be
More informationCSCI 2101 Java Style Guide
CSCI 2101 Java Style Guide Fall 2017 This document describes the required style guidelines for writing Java code in CSCI 2101. Guidelines are provided for four areas of style: identifiers, indentation,
More information// Initially NULL, points to the dynamically allocated array of bytes. uint8_t *data;
Creating a Data Type in C Bytes For this assignment, you will use the struct mechanism in C to implement a data type that represents an array of bytes. This data structure could be used kind of like a
More informationUIC. C Programming Primer. Bharathidasan University
C Programming Primer UIC C Programming Primer Bharathidasan University Contents Getting Started 02 Basic Concepts. 02 Variables, Data types and Constants...03 Control Statements and Loops 05 Expressions
More informationVISUAL GUIDE to. RX Scripting. for Roulette Xtreme - System Designer 2.0. L J Howell UX Software Ver. 1.0
VISUAL GUIDE to RX Scripting for Roulette Xtreme - System Designer 2.0 L J Howell UX Software 2009 Ver. 1.0 TABLE OF CONTENTS INTRODUCTION...ii What is this book about?... iii How to use this book... iii
More informationProgramming. C++ Basics
Programming C++ Basics Introduction to C++ C is a programming language developed in the 1970s with the UNIX operating system C programs are efficient and portable across different hardware platforms C++
More informationChapter 3. More Flow of Control. Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley
Chapter 3 More Flow of Control Overview 3.1 Using Boolean Expressions 3.2 Multiway Branches 3.3 More about C++ Loop Statements 3.4 Designing Loops Slide 3-3 Flow Of Control Flow of control refers to the
More informationUniversity of Technology. Laser & Optoelectronics Engineering Department. C++ Lab.
University of Technology Laser & Optoelectronics Engineering Department C++ Lab. Second week Variables Data Types. The usefulness of the "Hello World" programs shown in the previous section is quite questionable.
More information3 The L oop Control Structure
3 The L oop Control Structure Loops The while Loop Tips and Traps More Operators The for Loop Nesting of Loops Multiple Initialisations in the for Loop The Odd Loop The break Statement The continue Statement
More informationControl Structures in Java if-else and switch
Control Structures in Java if-else and switch Lecture 4 CGS 3416 Spring 2016 February 2, 2016 Control Flow Control flow refers to the specification of the order in which the individual statements, instructions
More informationIncrement and the While. Class 15
Increment and the While Class 15 Increment and Decrement Operators Increment and Decrement Increase or decrease a value by one, respectively. the most common operation in all of programming is to increment
More informationDiscussion 1H Notes (Week 3, April 14) TA: Brian Choi Section Webpage:
Discussion 1H Notes (Week 3, April 14) TA: Brian Choi (schoi@cs.ucla.edu) Section Webpage: http://www.cs.ucla.edu/~schoi/cs31 More on Arithmetic Expressions The following two are equivalent:! x = x + 5;
More informationUNIVERSITY OF CALIFORNIA, SANTA CRUZ BOARD OF STUDIES IN COMPUTER ENGINEERING
UNIVERSITY OF CALIFORNIA, SANTA CRUZ BOARD OF STUDIES IN COMPUTER ENGINEERING CMPE13/L: INTRODUCTION TO PROGRAMMING IN C SPRING 2012 Lab 3 Matrix Math Introduction Reading In this lab you will write a
More informationCS 342 Software Design Spring 2018 Term Project Part II Development of Question, Answer, and Exam Classes
CS 342 Software Design Spring 2018 Term Project Part II Development of Question, Answer, and Exam Classes Due: Wednesday 21 February. Electronic copy due at 3:30 P.M. Optional paper copy may be handed
More informationChapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. Overview. Objectives. Teaching Tips. Quick Quizzes. Class Discussion Topics
Java Programming, Sixth Edition 2-1 Chapter 2 Using Data At a Glance Instructor s Manual Table of Contents Overview Objectives Teaching Tips Quick Quizzes Class Discussion Topics Additional Projects Additional
More informationCS 342 Software Design Spring 2018 Term Project Part III Saving and Restoring Exams and Exam Components
CS 342 Software Design Spring 2018 Term Project Part III Saving and Restoring Exams and Exam Components Due: Wednesday 13 March. Electronic copy due at 3:30 P.M. Optional paper copy may be handed in during
More informationOutline. Overview. Control statements. Classes and methods. history and advantage how to: program, compile and execute 8 data types 3 types of errors
Outline Overview history and advantage how to: program, compile and execute 8 data types 3 types of errors Control statements Selection and repetition statements Classes and methods methods... 2 Oak A
More informationVARIABLES. Aim Understanding how computer programs store values, and how they are accessed and used in computer programs.
Lesson 2 VARIABLES Aim Understanding how computer programs store values, and how they are accessed and used in computer programs. WHAT ARE VARIABLES? When you input data (i.e. information) into a computer
More informationIf Statements, For Loops, Functions
Fundamentals of Programming If Statements, For Loops, Functions Table of Contents Hello World Types of Variables Integers and Floats String Boolean Relational Operators Lists Conditionals If and Else Statements
More informationCS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University
CS 112 Introduction to Computing II Wayne Snyder Department Boston University Today: Java basics: Compilation vs Interpretation Program structure Statements Values Variables Types Operators and Expressions
More informationExpressions and Data Types CSC 121 Spring 2015 Howard Rosenthal
Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types
More informationProgramming Lecture 3
Programming Lecture 3 Expressions (Chapter 3) Primitive types Aside: Context Free Grammars Constants, variables Identifiers Variable declarations Arithmetic expressions Operator precedence Assignment statements
More informationTips from the experts: How to waste a lot of time on this assignment
Com S 227 Spring 2018 Assignment 1 80 points Due Date: Friday, February 2, 11:59 pm (midnight) Late deadline (25% penalty): Monday, February 5, 11:59 pm General information This assignment is to be done
More informationCS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG
CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG 1 Notice Reading Assignment Chapter 1: Introduction to Java Programming Homework 1 It is due this coming Sunday
More informationChapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. A Guide to this Instructor s Manual:
Java Programming, Eighth Edition 2-1 Chapter 2 Using Data A Guide to this Instructor s Manual: We have designed this Instructor s Manual to supplement and enhance your teaching experience through classroom
More informationREVIEW. The C++ Programming Language. CS 151 Review #2
REVIEW The C++ Programming Language Computer programming courses generally concentrate on program design that can be applied to any number of programming languages on the market. It is imperative, however,
More informationCS 61B (Clancy, Yelick) Solutions and grading standards for exam 2 Spring 2001 Exam information
Exam information 345 students took the exam. Scores ranged from 3 to 25, with a median of 19 and an average of 18.1. There were 176 scores between 19 and 25, 125 between 12.5 and 18.5, 42 between 6 and
More informationCSE 143: Computer Programming II Summer 2015 HW6: 20 Questions (due Thursday, August 13, :30pm)
CSE 143: Computer Programming II Summer 2015 HW6: 20 Questions (due Thursday, August 13, 2015 11:30pm) This assignment focuses on binary trees and recursion. Turn in the following files using the link
More informationEE 382 Style Guide. March 2, 2018
EE 382 Style Guide March 2, 2018 This is a short document describing the coding style for this class. All code written in this class is assumed to follow this coding style. 1 Indentation Indentations should
More informationASSIGNMENT 2. COMP-202A, Fall 2013, All Sections. Due: October 20 th, 2013 (23:59)
ASSIGNMENT 2 COMP-202A, Fall 2013, All Sections Due: October 20 th, 2013 (23:59) Please read the entire PDF before starting. You must do this assignment individually and, unless otherwise specified, you
More informationLab 1 Implementing a Simon Says Game
ECE2049 Embedded Computing in Engineering Design Lab 1 Implementing a Simon Says Game In the late 1970s and early 1980s, one of the first and most popular electronic games was Simon by Milton Bradley.
More informationC++ Programming Style Guide
C++ Programming Style Guide Computer Science Program Cedarville University Goal: Our goal is to produce well-written code that can be easily understood and will facilitate life-cycle maintenance. These
More informationPointer Casts and Data Accesses
C Programming Pointer Casts and Data Accesses For this assignment, you will implement a C function similar to printf(). While implementing the function you will encounter pointers, strings, and bit-wise
More informationCS31 Discussion 1E. Jie(Jay) Wang Week1 Sept. 30
CS31 Discussion 1E Jie(Jay) Wang Week1 Sept. 30 About me Jie Wang E-mail: holawj@gmail.com Office hour: Wednesday 3:30 5:30 BH2432 Thursday 12:30 1:30 BH2432 Slides of discussion will be uploaded to the
More informationDecaf Language Reference Manual
Decaf Language Reference Manual C. R. Ramakrishnan Department of Computer Science SUNY at Stony Brook Stony Brook, NY 11794-4400 cram@cs.stonybrook.edu February 12, 2012 Decaf is a small object oriented
More informationCreating a C++ Program
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer. 1 Creating a C++ Program created using an
More informationMultiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible)
Name Closed notes, book and neighbor. If you have any questions ask them. Notes: Segment of code necessary C++ statements to perform the action described not a complete program Program a complete C++ program
More informationLESSON 2 VARIABLES, OPERATORS, EXPRESSIONS, AND USER INPUT
LESSON VARIABLES, OPERATORS, EXPRESSIONS, AND USER INPUT PROF. JOHN P. BAUGH PROFJPBAUGH@GMAIL.COM PROFJPBAUGH.COM CONTENTS INTRODUCTION... Assumptions.... Variables and Data Types..... Numeric Data Types:
More informationObjectives. In this chapter, you will:
Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates arithmetic expressions Learn about
More informationCSCS 261 Programming Concepts Exam 1 Fall EXAM 1 VERSION 1 Fall Points. Absolutely no electronic devices may be used during this exam.
Name: Print legibly! Section: COMPUTER SCIENCE 261 PROGRAMMING CONCEPTS EXAM 1 VERSION 1 Fall 2014 150 Points Absolutely no electronic devices may be used during this exam. 1. No cell phones, computers,
More informationCS 361 Computer Systems Fall 2017 Homework Assignment 1 Linking - From Source Code to Executable Binary
CS 361 Computer Systems Fall 2017 Homework Assignment 1 Linking - From Source Code to Executable Binary Due: Thursday 14 Sept. Electronic copy due at 9:00 A.M., optional paper copy may be delivered to
More informationUnit 3, Lesson 2 Data Types, Arithmetic,Variables, Input, Constants, & Library Functions. Mr. Dave Clausen La Cañada High School
Unit 3, Lesson 2 Data Types, Arithmetic,Variables, Input, Constants, & Library Functions Mr. Dave Clausen La Cañada High School Vocabulary Variable- A variable holds data that can change while the program
More information