CSCE 206 Lab Structured Programming in C

Slides:



Advertisements
Similar presentations
Variables in C Amir Haider Lecturer.
Advertisements

ARDUINO CLUB Session 1: C & An Introduction to Linux.
Lecture 2 Introduction to C Programming
Introduction to C Programming
CMPUT 101 Lab # 5 October 22, :00 – 17:00.
1 Lecture 2  Input-Process-Output  The Hello-world program  A Feet-to-inches program  Variables, expressions, assignments & initialization  printf()
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
Python November 18, Unit 7. So Far We can get user input We can create variables We can convert values from one type to another using functions We can.
Introduction to C Programming
Introduction to Python Lecture 1. CS 484 – Artificial Intelligence2 Big Picture Language Features Python is interpreted Not compiled Object-oriented language.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
Agenda Exam #1 Review Modulus Conditionals Boolean Algebra Reading: Chapter Homework #5.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
Control Structures (B) Topics to cover here: Sequencing in C++ language.
Computer Programming Control Structure
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 2 - Introduction to C Programming Outline.
1 Project 2: Using Variables and Expressions. 222 Project 2 Overview For this project you will work with three programs Circle Paint Ideal_Weight What.
 2007 Pearson Education, Inc. All rights reserved. A Simple C Program 1 /* ************************************************* *** Program: hello_world.
Homework 1 (due:April 8th) Deadline : April 8th 11:59pm Where to submit? eClass “ 과제방 ” ( How to submit? Create a folder. The name.
Variables in C Topics  Naming Variables  Declaring Variables  Using Variables  The Assignment Statement Reading  Sections
Variables in C Topics  Naming Variables  Declaring Variables  Using Variables  The Assignment Statement Reading  Sections
CMSC 104, Version 8/061L09VariablesInC.ppt Variables in C Topics Naming Variables Declaring Variables Using Variables The Assignment Statement Reading.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Introduction to C++
Dr. Sajib Datta Jan 15,  Instructor: Sajib Datta ◦ Office Location: ERB 336 ◦ Address: ◦ Web Site:
1 Project 4: Computing Distance. 222 Computing Distance Write a program to compute the distance between two points. Recall that the distance between the.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
An Introduction to Programming with C++ Sixth Edition Chapter 5 The Selection Structure.
Quiz 1 A sample quiz 1 is linked to the grading page on the course web site. Everything up to and including this Friday’s lecture except that conditionals.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
2.1 The Part of a C++ Program. The Parts of a C++ Program // sample C++ program #include using namespace std; int main() { cout
BIT116: Scripting Lecture 05
Precedence Operators Error Types
Whatcha doin'? Aims: To start using Python. To understand loops.
ECE Application Programming
Jie(Jay) Wang Week1 Sept. 30
Introduction to Python
Chapter 2 - Introduction to C Programming
The Selection Structure
Variables, Expressions, and IO
Chapter 2 - Introduction to C Programming
IPC144 Introduction to Programming Using C Week 2 – Lesson 1
2008/10/01: Lecture 8 CMSC 104, Section 0101 John Y. Park
Chapter 2 - Introduction to C Programming
Chapter 11 Introduction to Programming in C
Chapter 2 - Introduction to C Programming
2.1 Parts of a C++ Program.
Number and String Operations
CSCE 206 Lab Structured Programming in C
Chapter 2 - Introduction to C Programming
Escape sequences: Practice using the escape sequences on the code below to see what happens. Try this next code to help you understand the last two sequences.
Variables in C Topics Naming Variables Declaring Variables
Chapter 2 - Introduction to C Programming
Documentation and Style
Chapter 2: Introduction to C++.
C++ Programming Lecture 3 C++ Basics – Part I
Chapter 2 - Introduction to C Programming
Let’s start from the beginning
Variables Lesson Outline
EECE.2160 ECE Application Programming
EECE.2160 ECE Application Programming
Announcements: Questions: Names on the board? Why?
Variables in C Topics Naming Variables Declaring Variables
CSCE 206 Lab Structured Programming in C
2008/10/01: Lecture 8 CMSC 104, Section 0101 John Y. Park
CSCE 206 Lab Structured Programming in C
CSCE 206 Lab Structured Programming in C
EECE.2160 ECE Application Programming
Introduction to C Programming
Class code for pythonroom.com cchsp2cs
Presentation transcript:

CSCE 206 Lab Structured Programming in C Spring 2019 HW1 COMMON ERRORS

File submission 1 compressed zip file (named as specified in the instructions) containing ONE .c file per question which must be called: HW1_Q1.c Not: LAB1_Q1.c, Problem1.c, HW1_Q1.c.c, hw1_q1.c or anything different Not: everything in a single .c file, that will never compile because of multiple definitions of main() No intermediate folder: compress the 3 files, not a folder containing the 3 files! Sorry for the confusion of HW vs LAB in the naming, I used the same instructions from the previous semester and after publishing the instructions I don’t want to confuse more people by changing it. This shouldn’t be a problem if you correctly create your folders, either in your laptop or the server: 1 folder for the course like “cse206” with two folders, one for “lectures”, another one for “labs” and in labs you have another folder for lab “problems” and another folder for “assignments”. In assignments you will have HW1, HW2, HW3, … If you organize your folders this way everything should be easier and more clear. They MUST compile and run in the linux2 server. It is YOUR responsibility to check that. Be able to compile it and run it in visual studio, online or anywhere else won’t get you the points! Remember, compile and run correctly is 80% of your grade!! The sample inputs and outputs specified in the questions are for you to practice, if they are divided by a line, it means they are different inputs. If it is not specified that you need to run the same program for X number of times, do so just to comply with one input set at a time.

Code mistakes Do not change the output. It should be as stated in the question. If it says to output with lowercase, use lowercase If it has a $, put it; if it has “yards” do not write “yd” “Number-1:”, write that and not “what is your first number” No extra printf(), do not write things like “Problem 2:” In the question I put the parts of the output of the program in red to differentiate from the user input. But DO NOT output in red. I will just see weird characters. To specify a number of decimals in printf() in a floating point you need to use %.2f where 2 is the number of decimals, in that case 2, e.g. “18.43” Variables should start in lowercase always Should have meaningful names: if you have 2 items that have price and quantity, just call them “price1”, “quantity1”, “discount”. This makes the program readable AND you can avoid explaining in the comments what each variable means!

Code comments As per the instructions in my website you need to put a block comment at the start of the file: Example of a good comment in Q2: // 1yd == 3ft and 1 ft == 12 inch, to convert from inches to yards, I divided the inches by 3*12=36 --> yd = inches/36 Comments are placed on or before the line they are about (never afterwards!) All hardcoded values need to be explained!

Code improvement Variable naming is very important to make your program readable Do not use all letters of the alphabet (int a, b, c, d, e), use instead something descriptive like “price1, quantity1, input_inches, … You can do “total = total*sales_tax” instead of creating 2 variables (1 for the first calculation, another one for the second part Always use parenthesis around a long operation that contains multiple operators with different order priorities (e.g. (x*y)+z), even if you know what you are doing, don’t leave it to ‘luck’ Always use “{“ and “}” for EVERY if, else, for, while, … And everything inside the brackets need to go on the same indentation level, including comments! And no extra new lines between the bracket and the function or statement that they belong to: E.g.: if (condition) {