CS : Programming for Non-majors, Fall 2018 Programming Project #2: Census Due by 10:20am Wednesday September

Size: px
Start display at page:

Download "CS : Programming for Non-majors, Fall 2018 Programming Project #2: Census Due by 10:20am Wednesday September"

Transcription

1 CS : Programming for Non-majors, Fall 2018 Programming Project #2: Census Due by 10:20am Wednesday September This second assignment will introduce you to designing, developing, testing and debugging your own C program, as well as to declaring variables, inputting and outputting. You will also learn to add new projects to your makefile. I. PROBLEM DESCRIPTION You are a software developer for the United States Census Bureau, working on software for the 2020 Census. The particular program that you re developing will ask three questions about a census subject: 1. the average number of meals that the subject eats in restaurants per month; 2. the average number of help sessions that the subject attends per semester; 3. the subject s cell phone number. Notice that the average number of meals eaten in restaurants per month MIGHT NOT BE AN INTEGER; for example, a person might average 8.5 meals eaten in restaurants per month. Likewise, the person might average help sessions attended per semester. Note that a number that doesn t have to be an integer is known in mathematics as a real number, and is also known in computing as a floating point number. On the other hand, notice that a person s cell phone number can be expressed as three integers (the area code, the prefix and the line number), 1 separated by hyphens; for example: So, this program will have a user input two real numbers (average number of meals eaten in restaurants per month, average number of help sessions attended per semester). and three integers (the parts of the cell phone number). Write a program to perform the above task. Note that your program MUST begin with a declaration section in which you declare all necessary variables. This will be followed by the execution section (body), which will: 1. greet the user and explain what the program does, and then 2. prompt the user and input the five numbers, and then 3. output the five numbers. Details follow. Please read all of this specification CAREFULLY. Remember, every word Dr. Neeman writes down is PURE GOLD. This programming project specification contains many small code examples. In most cases, these code examples will be extremely useful in your actual PP#2. We urge you to use them

2 II. WHAT TO DO FIRST: Insert an Entry for the New Project into Your Makefile AS THE VERY FIRST STEP, in your makefile, insert a makefile entry for the new program, so that, when you re ready to compile your new program, you can use make instead of having to use the gcc command directly (which would risk disaster). Your C source file MUST be named census.c and your executable MUST be named census Using your preferred text editor (for example, nano), edit your makefile (which is named makefile) to include the following lines at the TOP of the makefile, ABOVE the make entry for Programming Project #1 (PP#1), with a blank line between the entries for PP#2 and PP#1: census: census.c gcc -o census census.c In the gcc command, the filename after -o should be the executable (NO.c extension), and the filename at the end should be the C source file (WITH the.c extension). DON T DELETE THE MAKE ENTRY FOR PROGRAMMING PROJECT #1, nor any other make entry, EVER. On the first line, above, between the colon and the name of the C source file, there are one or more tabs (on most keyboards, it s in the upper left, to the left of the Q key). There are NO SPACES between the colon and the filename. On the second line, immediately before the gcc, there are one or more tabs. There are NO SPACES immediately before the gcc. Also in the makefile, alter the clean entry (the bottommost entry in the makefile) by putting in another rm command, like so: clean: rm -f my_number rm -f census NOTES: DON T DELETE THE rm COMMAND FOR PROGRAMMING PROJECT #1, nor any other rm command, EVER. In the new rm command, above, immediately before the rm, there are one or more tabs. There are NO SPACES immediately before the rm. NEVER put ANYTHING on the same line as clean: regardless of what it may be that you want to put there. LEAVE THAT LINE COMPLETELY ALONE! In the clean entry, the file to be removed with the rm should ALWAYS ALWAYS ALWAYS be the EXECUTABLE (for PP#2, census) and NEVER NEVER NEVER a source file. NOTE: You MUST use the lecture slide packets titled C Introduction, Variables and Standard I/O to complete this project. You should study every single slide CAREFULLY. You can also look at the Software and Constants packets, but the bulk of the crucial information will be in the C Introduction, Variables and Standard I/O packets. 2

3 III. DETAILED DESCRIPTION OF THE PROGRAM HOW TO EDIT A FILE THAT DOESN T EXIST YET As noted in section II, above, your C source file for PP#2 MUST be named census.c and your executable MUST be named census But when you start working on PP#2, the C source file named census.c doesn t exist yet. Question: If a file doesn t exist yet, how can you edit it? Answer: Pretend that the file already exists, and edit it just as if that were true. The first time you save what you re editing, the file will come to exist. When you re editing a file, remember to save your work OFTEN, preferably every few minutes. A. BASIC STRUCTURE OF THE PROGRAM OTHER THAN COMMENTS (see Grading Criteria, below), the program MUST begin with the following preprocessor directive: #include <stdio.h> OTHER THAN COMMENTS (see Grading Criteria, below), the program MUST then have the main function header, followed on the next line by the main function block open, and, AT THE END OF THE PROGRAM, the main function block close on a line by itself. The main function block open and the main function block close will each have, following it on its same line, a blank space, followed by the comment open delimiter, followed by a blank space, followed by the word main in all lower case, followed by a blank space, followed by the comment close delimiter. So the basic structure of the program, OTHER THAN COMMENTS (see Grading Criteria, below), will look like this: #include <stdio.h> int main () { /* main */ } /* main */ INSIDE the main function that is, between the block open and the block close of the main function FIRST should be the declaration section, FOLLOWED BY the execution section (body) of the program, IN THAT ORDER. B. STRUCTURE OF THE DECLARATION SECTION In the declaration section, OTHER THAN COMMENTS (see Grading Criteria, below), FIRST should be ALL float variable declarations, FOLLOWED BY ALL int variable declarations. If you wish, you may put multiple variables of the SAME DATA TYPE in the same declaration statement, or you may use an individual declaration statement for each variable, or you may do some of each. 3

4 C. STRUCTURE OF THE EXECUTION SECTION (BODY) The EXECUTION SECTION (BODY) of the program MUST have the following structure and MUST be in the following order interleaving these pieces is ABSOLUTELY FORBIDDEN: 1. Greeting Subsection: Your program MUST begin by outputting a helpful message telling the user what the program does. This message may be a single line of output text, or multiple lines of output text. ALL OUTPUTS, THROUGHOUT THE ENTIRE PROGRAM, MUST BE MEANINGFUL, COMPLETE ENGLISH SENTENCES. 2. Input Subsection (a) Input the first real (floating point) quantity: i. Prompt the user to input the subject s average number of meals eaten in restaurants per month. ii. Input the subject s average number of meals eaten in restaurants per month. (b) Input the second real (floating point) quantity: i. Prompt the user to input the subject s average number of help sessions attended per semester. ii. Input the subject s average number of help sessions attended per semester. (c) Input the subject s cell phone number: i. Prompt the user to input the subject s cell phone number as three integers, separated by blank spaces (see section V); for example, printf("what is the subject s cell phone number\n"); printf(" (area code, prefix, line number, "); printf(" separated by blank spaces)?\n"); ii. Input the three integers in the above order, using a single scanf statement to read all three int variables from a single line of input text. 3. Output Subsection: (a) Output the subject s average number of meals eaten in restaurants per month, including helpful explanatory text; for example, the output text might look like: The subject eats an average of meals in restaurants per month. (b) Output the subject s average number of help sessions attended per semester, including helpful explanatory text. (c) Output the subject s cell phone number, including helpful explanatory text. This output MUST use the 3-part hyphenated notation shown on page 1. (The output may contain extra spaces between the numbers and the hyphens.) For example, the output text might look like: The subject s cell phone number is We encourage you to make your comments and outputs entertaining, but not profane or offensive. The real (floating point) numbers that you output may come out with a weird format, like this: The subject eats an average of meals in restaurants per month. For runs #2 and #3, which will use values that you ve chosen, you may see something like this: The subject attends an average of help sessions per semester. If either of these happens, DON T PANIC! THESE ARE NORMAL, so don t worry about them. 4

5 IV. ADVICE ON HOW TO WRITE A PROGRAM When you re writing a program: 1. write a little bit of the source code; 2. make; 3. if the make fails, then debug the source code; 4. when the make succeeds, then run; 5. if the run fails, then debug the source code; 6. when the run succeeds, then go on and write a little more, and so on. For example, in the case of this program: 1. Start by writing the skeleton of the source code: the #include directive, the main function header, the main function block open and block close. and appropriate comments for these items. Then make, then run. (This run won t be very interesting, unless the program crashes, in which case debug it.) 2. Then, write the variable declarations, with appropriate comments. Then make, then run. (This run won t be very interesting, unless the program crashes, in which case debug it.) 3. Then, write the greeting subsection, with appropriate comments. Then make, then run. 4. Then, write the input subsection, with appropriate comments. Then make, then run. 5. Then, write the output subsection, with appropriate comments. Then make, then run. Also, in your preferred text editor (for example, nano), FREQUENTLY SAVE YOUR WORK. Specifically, we recommend that, in your preferred text editor, you SAVE YOUR WORK EVERY FEW MINUTES. (For example, in nano, press Ctrl-O to save your work, and do this every few minutes.) NOTE: When you write a comment open delimiter (slash asterisk), you should IMMEDIATELY write the comment close delimiter (asterisk slash) so that you don t end up forgetting it later and then you can put the actual comment text in between. Likewise, when you write a block open delimiter (open curly brace), you should IMMEDIATELY write the block close delimiter (close curly brace) so that you don t end up forgetting it later and then you can put the actual source code text of the main function in between. When you re editing a file, remember to save your work OFTEN, preferably every few minutes. 5

6 V. RUNS In the script session that produces your script file (described below), you MUST run your program three times. For the first run, use the following inputs: average number of meals eaten in restaurants per month: 8.5; average number of help sessions attended per semester: 11.25; cell phone number: Note that this should be input as but it should be output as (along with helpful explanatory text). When you input the subject s cell phone number at runtime, DON T INPUT ANY HYPHENS. Instead, separate the pieces of the cell phone number with spaces (preferred) or carriage returns. For the second and third runs, choose any VALID answers to these questions that you want, but all three runs MUST have different inputs for all questions; that is, every question MUST have different answers for each of the three runs, and all inputs within a run must differ from each other. NOTE: You are ABSOLUTELY FORBIDDEN to use any cell phone number that starts with a zero in the leftmost digit of any of the three pieces. DON T USE YOUR OWN CELL PHONE NUMBER AS INPUT, nor that of anyone else that you know. VI. WHAT TO SUBMIT Before creating your script file, THOROUGHLY TEST AND DEBUG YOUR PROGRAM. Once you are satisfied with your program, create your script file, which MUST be named: pp2.txt Use the procedure described in the Programming Project #1 specification to create your script file, except replacing census for my number and census.c for my number.c, doing three runs using the input values that you ve tested (section V, above). CAREFULLY PROOFREAD THE PRINTOUT OF YOUR SCRIPT FILE. Frequently, students lose SIGNIFICANT CREDIT because of failure to proofread. Especially, CHECK YOUR MAKE COMMANDS to be sure (a) that you did them and (b) that they worked properly. Cover and Summary: You MUST create a cover page and a summary essay following the same rules as in Programming Project #1. PRINT your cover, summary and script file, using the method described in the PP#1 specification. For full credit on PP#2 (and ALL future programming projects), you MUST submit a paper submission AND upload to Canvas (see below). Binding Order: You MUST bind, IN THIS ORDER, the cover page, then the summary, then the script, then the bottom half of the extra credit form (at the very end), if applicable (see below). Thus, for binding PP#2, follow the same rules as in PP#1. Upload to Canvas: You also MUST upload your source file and script file to Canvas, as you did for PP#1, but into the place for this project. 6

7 VII. GRADING CRITERIA The following grading criteria will apply to ALL CS1313 programming projects, unless explicitly stated otherwise. Grading Criteria for Cover Page, Summary Essay, Script File and Upload to Canvas: The rules and grading criteria for the cover page, summary essay, script file and upload to Canvas, as described in the Programming Project #1 specification, also apply to the cover page, summary essay, script file and upload for Programming Project #2, and will also apply to all future Programming Projects unless explicitly stated otherwise. Failure to upload the correct files to the correct place in Canvas by the PP#2 deadline may cost you up to 5% of the total value of PP#2, right off the top before any other deductions are applied. You MUST properly do the make clean and make census steps in your script. FAILING TO PROPERLY DO THE make clean AND/OR make census STEPS, OR HAVING A COMPILE FAIL DUE TO ERRORS, WILL COST YOU AT LEAST 50% OF THE POINTS FOR THIS PROGRAMMING PROJECT, right off the top before any other deductions are applied. COMPILER WARNINGS in response to the make census step other than the clock skew warning WILL COST YOU AT LEAST 25% OF THE POINTS FOR THIS PROGRAMMING PROJECT, right off the top before any other deductions are applied. Grading Criteria for C Source Code 1. Documentation MUST be similar to that in my number.c, and will count for at least 10% of the total value of this project. (a) The program MUST be preceded by a comment block, as shown in my number.c. (b) The declaration section and the execution section (body) MUST be clearly labeled, as shown in my number.c. (c) Variable declarations MUST be preceded by comments explaining the nature and purpose of each declared name, as shown in my number.c. (d) Each subsection of the execution section (body) of the program greeting, input, output MUST be clearly labeled, as shown in my number.c. (e) EVERY executable statement MUST be preceded by a comment that clearly explains what the statement does, well enough so that even a non-programmer could understand. Exception: Multiple printf statements in a row that together output a single message need a comment only before the first of them. (f) ALL comments MUST use the format shown below. Specifically, the first line of the comment MUST simply be the comment open delimiter (slash asterisk), and the last line MUST simply be the comment close delimiter (asterisk slash). All other lines MUST have, as their first non-blank character, an asterisk, followed by a blank space, followed by the text of the comment. ALL of the asterisks MUST line up with the text of the program statement that the comment describes. For example: /* * Output to the terminal screen the subject s * average number of meals eaten in restaurants per month. */ printf("the subject averages %f meals eaten in restaurants per month.\n", average_monthly_restaurant_meals_eaten); 7

8 2. Block open/block close comments: The block open and block close for the main function MUST each be followed, on the same line, by a comment indicating that the block that they begin and end is the main function. Specifically, the line with the block open or the block close MUST have the following structure: the block open or block close, followed by a single blank space, followed by the comment open delimiter, followed by a single blank space, followed by the keyword main, followed by a single blank space, followed by the comment close delimiter. For example: { /* main */ } /* main */ 3. Section order: The section order MUST be as follows: the declaration section, followed by the executable section (body), as shown in my number.c. Therefore, ALL declarations MUST appear BEFORE ANY executable statements. 4. Identifier structure: Identifiers such as variable names MUST be in ALL LOWER CASE, except where upper case is appropriate as part of a proper name (for example, population of Oklahoma). Adjacent words in an identifier MUST be separated by an underscore. 5. Favorite professor rule for identifiers: Identifiers such as variable names MUST strictly observe the favorite professor rule, as described in the lecture slides. Meaningless, obscure or cryptic names will be penalized, as will abbreviations that aren t in common use in nonprogramming contexts. 6. Data types: EVERY variable MUST have an appropriate data type. Inappropriate data types will be penalized. 7. Variable declaration grouping: Variable declarations MUST be grouped by data type; that is, you MUST first declare ALL float variables, followed by ALL int variables. 8. Variable declaration statement structure MUST be as follows: the indentation, followed by the data type, followed by one or more blank spaces, followed by the name of the variable, followed by the statement terminator (or you may declare multiple variables in the same declaration statement, separated by commas and with a statement terminator at the end, as shown in the lecture slides). 9. Variable declaration spacing MUST have the following property: The first character of the first variable name of ALL declaration statements, regardless of data type, should be in the same column of source code text. In the case of PP#2, this means that, in a float variable declaration, there should be EXACTLY ONE blank space after the keyword float, and in an int variable declaration, there should be EXACTLY THREE blank spaces after the keyword int. (In other Programming Projects, the blank space counts may differ, but the principle will be the same.) For example: int main () { /* main */ float average_monthly_restaurant_meals_eaten; float average_semesterly_help_sessions_attended; int area_code, prefix, line_number; } /* main */ 8

9 10. Multiple variables in the same declaration statement: An individual declaration statement may declare multiple variables, but it is STRONGLY RECOMMENDED that this be done only when the variables are very closely related to one another. If an individual declaration statement declares multiple variables, then in its comma-separated list of variable names, each comma MUST be followed by a single blank space, as shown in the example just above. If the multiple variables would exceed the proper length of a line of source code text, then the declaration statement may continue on to the next line, in which case, in the subsequent line(s) of the declaration statement, the first variable name of each line should line up with the first variable name of the first line of the declaration statement. 11. Indentation MUST be used properly and consistently. The #include directive and the main function header MUST NOT BE INDENTED AT ALL (that is, they MUST begin in the leftmost column). Likewise, the main function s block open (open curly brace {) and the block close (close curly brace }) MUST NOT BE INDENTED AT ALL. ALL OTHER STATEMENTS, both declarations and executable statements, MUST be indented an additional FOUR SPACES beyond the function header. For example: #include <stdio.h> int main () { /* main */ float average_monthly_restaurant_meals_eaten; printf("the subject averages %f meals eaten in restaurants per month.\n", average_monthly_restaurant_meals_eaten); } /* main */ NOTE: If a statement uses more than one line of source code text, then the second line (and beyond) of source code text of that statement MUST be indented farther, preferably 4 spaces farther than the first line of the statement, as shown in the example just above. IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT!!! Indenting is SO INCREDIBLY IMPORTANT that it s worth at least 10% of your overall score on PP#2 (A FULL LETTER GRADE)! 12. Subsection order in the execution section: In the execution section, the subsection order MUST be as follows: the greeting subsection, followed by the input subsection, followed by the output subsection. 13. Execution subsection contents: In the execution section: the greeting subsection is ABSOLUTELY FORBIDDEN to contain any inputs; the only outputs that may be in the input subsection are prompts for inputs; the output subsection is ABSOLUTELY FORBIDDEN to contain any inputs. 14. The length of each line of C source code text MUST be less than 80 characters (the width of a typical PuTTY window); 72 characters or less is preferred. 15. The length of each line of output text MUST be less than 80 characters; 72 characters or less is preferred. 9

10 16. printf WITHOUT placeholders: EVERY printf statement that DOESN T contain any placeholders MUST have the following structure: indentation, followed by the word printf, followed by an open parenthesis, followed by a double quote, followed by the text of the string literal (probably but not necessarily ending with a newline), followed by a double quote, followed by a close parenthesis, followed by the statement terminator. For example: printf("what is the subject s cell phone number\n"); printf(" (area code, prefix, line number, "); printf("separated by spaces)?\n"); 17. printf WITH placeholders: EVERY printf statement that DOES contains one or more placeholder(s) MUST have the following structure: indentation, followed by the word printf, followed by an open parenthesis, followed by a double quote, followed by the text of the string literal including placeholder(s) (probably but not necessarily ending with a newline), followed by a double quote, followed by a comma, followed by a blank space, followed by the comma-separated list of variables whose values are replacing the placeholder(s), with a blank space after each comma, followed by a close parenthesis, followed by the statement terminator. For example: printf("the subject averages %f meals eaten in restaurants per month.\n", average_monthly_restaurant_meals_eaten); 18. Newlines in printf statements. Every line of output text MUST end with a newline. The last (or only) printf statement for a particular line of output text MUST have a newline \n as the LAST characters in its string literal, immediately before the double quote that ends that string literal. See above for examples. 19. scanf: EVERY scanf statement MUST have the following structure: indentation, followed by the word scanf, followed by an open parenthesis, followed by a double quote, followed by the text of the string literal including placeholder(s), followed by a double quote, followed by a comma, followed by a blank space, followed by the comma-separated list of variables whose values are being input each preceded by an ampersand & with no blank space after the ampersand with a blank space after each comma, followed by a close parenthesis, followed by the statement terminator. For example: scanf("%f", &average_monthly_restaurant_meals_eaten); 20. Newlines in scanf statements are FORBIDDEN. A scanf statement CANNOT have a newline \n anywhere in its string literal. See above for an example. 21. String literals MUST NOT have carriage returns embedded inside them. So, the following statement is BAD BAD BAD: printf("this is a very long sentence so it needs to be broken into pieces.\n"); The output text above MUST be broken into multiple printf statements, so the following statements are GOOD: printf("this is a very long sentence so it needs"); printf(" to be broken into pieces.\n"); Note that the resulting line of output text MUST be less than 80 characters long, preferably no more than Once you ve created your script file, you are ABSOLUTELY FORBIDDEN to alter your script file IN ANY WAY, EVER. (But, you may replace it with a completely new script file.) 10

11 EXTRA CREDIT You can receive an extra credit bonus of as much as 5% of the total value of PP#2 by doing the following: 1. Attend at least one regularly scheduled CS1313 help session for at least 30 minutes, through Wed Sep During the regularly scheduled help session that you attend, work on CS1313 assignments (ideally PP#2, but any CS1313 assignment is acceptable). YOU CANNOT GET EXTRA CREDIT IF YOU DON T WORK ON CS1313 ASSIGNMENTS DURING THE HELP SESSION. 3. Before you leave the regularly scheduled help session, fill out BOTH halves of the form on the last page of this project specification and have the help session leader (instructor or TA) sign BOTH halves. THE FORM CANNOT BE SIGNED UNTIL IT IS COMPLETELY FILLED OUT IN INK. Use of pencil on these forms is ABSOLUTELY FORBIDDEN. 4. If you leave the help session without getting the form signed, you CANNOT get extra credit for attending that help session; your form CANNOT be signed later. 5. Attach the bottom half of the form to your PP#2 script printout, AFTER the script itself, and keep the top half for your own records. VALUE OF THE EXTRA CREDIT BONUS: for attending a regularly scheduled help session Mon Sep 10 - Wed Sep 12: 5% of the total value of PP#2; for attending a regularly scheduled help session Mon Sep 17 - Wed Sep 19: 2.5% of the total value of PP#2. NOTES: You can only get the extra credit bonus ONCE per programming project that offers it. This extra credit bonus WON T be available on any other programming project unless explicitly stated so in that project s specification. 11

12 THIS PAGE INTENTIONALLY LEFT BLANK. 12

13 CS1313 PROGRAMMING PROJECT #2 BONUS REQUEST FORM Name Help Session Date Help Session Time (Arrive) Lab Help Session Time (Depart) Instructor Signature Keep this copy for your records. CS1313 PROGRAMMING PROJECT #2 BONUS REQUEST FORM Name Help Session Date Help Session Time (Arrive) Lab Help Session Time (Depart) Instructor Signature Submit this copy. In your submission, attach this copy AFTER your script file printout. If you put this in the wrong place in your submission, then you WON T get the extra credit. 13

CS : Programming for Non-majors, Summer 2007 Programming Project #2: Census Due by 12:00pm (noon) Wednesday June

CS : Programming for Non-majors, Summer 2007 Programming Project #2: Census Due by 12:00pm (noon) Wednesday June CS 1313 010: Programming for Non-majors, Summer 2007 Programming Project #2: Census Due by 12:00pm (noon) Wednesday June 20 2007 This second assignment will introduce you to designing, developing, testing

More information

CS : Programming for Non-Majors, Fall 2018 Programming Project #5: Big Statistics Due by 10:20am Wednesday November

CS : Programming for Non-Majors, Fall 2018 Programming Project #5: Big Statistics Due by 10:20am Wednesday November CS 1313 010: Programming for Non-Majors, Fall 2018 Programming Project #5: Big Statistics Due by 10:20am Wednesday November 7 2018 This fifth programming project will give you experience writing programs

More information

C Introduction Lesson Outline

C Introduction Lesson Outline Outline 1. Outline 2. hello_world.c 3. C Character Set 4. C is Case Sensitive 5. Character String Literal Constant 6. String Literal Cannot Use Multiple Lines 7. Multi-line String Literal Example 8. Newline

More information

CpSc 1111 Lab 4 Part a Flow Control, Branching, and Formatting

CpSc 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 information

CS/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 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 information

Welcome to... CS113: Introduction to C

Welcome to... CS113: Introduction to C Welcome to... CS113: Introduction to C Instructor: Erik Sherwood E-mail: wes28@cs.cornell.edu Course Website: http://www.cs.cornell.edu/courses/cs113/2005fa/ The website is linked to from the courses page

More information

Fundamentals of Programming Session 4

Fundamentals of Programming Session 4 Fundamentals of Programming Session 4 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2011 These slides are created using Deitel s slides, ( 1992-2010 by Pearson Education, Inc).

More information

CS125 : Introduction to Computer Science. Lecture Notes #4 Type Checking, Input/Output, and Programming Style

CS125 : Introduction to Computer Science. Lecture Notes #4 Type Checking, Input/Output, and Programming Style CS125 : Introduction to Computer Science Lecture Notes #4 Type Checking, Input/Output, and Programming Style c 2005, 2004, 2002, 2001, 2000 Jason Zych 1 Lecture 4 : Type Checking, Input/Output, and Programming

More information

CpSc 1111 Lab 9 2-D Arrays

CpSc 1111 Lab 9 2-D Arrays CpSc 1111 Lab 9 2-D Arrays Overview This week, you will gain some experience with 2-dimensional arrays, using loops to do the following: initialize a 2-D array with data from an input file print out the

More information

CS : Programming for Non-majors, Spring 2003 Programming Project #1: Thinking of a Number Due by 10:20am Monday January

CS : Programming for Non-majors, Spring 2003 Programming Project #1: Thinking of a Number Due by 10:20am Monday January CS 1313 010: Programming for Non-majors, Spring 2003 Programming Project #1: Thinking of a Number Due by 10:20am Monday January 27 2003 http://cs1313.ou.edu/ This first assignment will help you learn to

More information

CpSc 1111 Lab 4 Formatting and Flow Control

CpSc 1111 Lab 4 Formatting and Flow Control CpSc 1111 Lab 4 Formatting and Flow Control Overview By the end of the lab, you will be able to: use fscanf() to accept a character input from the user and print out the ASCII decimal, octal, and hexadecimal

More information

CS Spring 2018 Homework #5

CS Spring 2018 Homework #5 CS 1313 010 Spring 2018 Homework #5 Quiz to be held in lecture 9:30-9:45am Mon Feb 19 2018 1. HOW CAN YOU TELL that a declaration statement declares a named constant? 2. HOW CAN YOU TELL that a declaration

More information

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language 1 History C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was originally first implemented on the DEC

More information

CS : Programming for Non-majors, Spring 2018 Programming Project #1: Thinking of a Number Due by 10:20am Wednesday January

CS : Programming for Non-majors, Spring 2018 Programming Project #1: Thinking of a Number Due by 10:20am Wednesday January CS 1313 010: Programming for Non-majors, Spring 2018 Programming Project #1: Thinking of a Number Due by 10:20am Wednesday January 31 2018 This first assignment will help you learn to use the Linux computers

More information

Programming Standards: You must conform to good programming/documentation standards. Some specifics:

Programming Standards: You must conform to good programming/documentation standards. Some specifics: CS3114 (Spring 2011) PROGRAMMING ASSIGNMENT #3 Due Thursday, April 7 @ 11:00 PM for 100 points Early bonus date: Wednesday, April 6 @ 11:00 PM for a 10 point bonus Initial Schedule due Thursday, March

More information

Software Lesson 1 Outline

Software Lesson 1 Outline Software Lesson 1 Outline 1. Software Lesson 1 Outline 2. What is Software? A Program? Data? 3. What are Instructions? 4. What is a Programming Language? 5. What is Source Code? What is a Source File?

More information

C++ Style Guide. 1.0 General. 2.0 Visual Layout. 3.0 Indentation and Whitespace

C++ 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 information

CS 1044 Program 6 Summer I dimension ??????

CS 1044 Program 6 Summer I dimension ?????? Managing a simple array: Validating Array Indices Most interesting programs deal with considerable amounts of data, and must store much, or all, of that data on one time. The simplest effective means for

More information

POFT 2301 INTERMEDIATE KEYBOARDING LECTURE NOTES

POFT 2301 INTERMEDIATE KEYBOARDING LECTURE NOTES INTERMEDIATE KEYBOARDING LECTURE NOTES Be sure that you are reading the textbook information and the notes on the screen as you complete each part of the lessons in this Gregg Keyboarding Program (GDP).

More information

CpSc 1111 Lab 5 Formatting and Flow Control

CpSc 1111 Lab 5 Formatting and Flow Control CpSc 1111 Lab 5 Formatting and Flow Control Overview By the end of the lab, you will be able to: use fscanf() to accept a character input from the user execute a basic block iteratively using loops to

More information

3. A Periodic Alarm: intdate.c & sigsend.c

3. A Periodic Alarm: intdate.c & sigsend.c p6: Signal Handling 1. Logistics 1. This project must be done individually. It is academic misconduct to share your work with others in any form including posting it on publicly accessible web sites, such

More information

Formatting & Style Examples

Formatting & 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 information

CS 1428 Programming Assignment 2 Due Wednesday September 19 th :15 am Section 3 3:45 pm Section 4

CS 1428 Programming Assignment 2 Due Wednesday September 19 th :15 am Section 3 3:45 pm Section 4 CS 1428 Programming Assignment 2 Due Wednesday September 19 th 2018 11:15 am Section 3 3:45 pm Section 4 Program 2: Write a C++ program to create a customer s bill for a company. The company sells only

More information

Slide Set 2. for ENCM 335 in Fall Steve Norman, PhD, PEng

Slide Set 2. for ENCM 335 in Fall Steve Norman, PhD, PEng Slide Set 2 for ENCM 335 in Fall 2018 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary September 2018 ENCM 335 Fall 2018 Slide Set 2 slide

More information

AN OVERVIEW OF C. CSE 130: Introduction to Programming in C Stony Brook University

AN OVERVIEW OF C. CSE 130: Introduction to Programming in C Stony Brook University AN OVERVIEW OF C CSE 130: Introduction to Programming in C Stony Brook University WHY C? C is a programming lingua franca Millions of lines of C code exist Many other languages use C-like syntax C is portable

More information

Decision Logic: if, if else, switch, Boolean conditions and variables

Decision 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 information

CS 426 Fall Machine Problem 1. Machine Problem 1. CS 426 Compiler Construction Fall Semester 2017

CS 426 Fall Machine Problem 1. Machine Problem 1. CS 426 Compiler Construction Fall Semester 2017 CS 426 Fall 2017 1 Machine Problem 1 Machine Problem 1 CS 426 Compiler Construction Fall Semester 2017 Handed Out: September 6, 2017. Due: September 21, 2017, 5:00 p.m. The machine problems for this semester

More information

CS 356, Fall 2018 Data Lab (Part 2): Manipulating Bits Due: Mon, Sep. 17, 11:59PM

CS 356, Fall 2018 Data Lab (Part 2): Manipulating Bits Due: Mon, Sep. 17, 11:59PM CS 356, Fall 2018 Data Lab (Part 2): Manipulating Bits Due: Mon, Sep. 17, 11:59PM 1 Introduction This second part of the data lab continues on bit-level manipulations and 2 s complement arithmetic as well

More information

CS1 Lecture 3 Jan. 22, 2018

CS1 Lecture 3 Jan. 22, 2018 CS1 Lecture 3 Jan. 22, 2018 Office hours for me and for TAs have been posted, locations will change check class website regularly First homework available, due Mon., 9:00am. Discussion sections tomorrow

More information

Laboratory Assignment #3 Eclipse CDT

Laboratory Assignment #3 Eclipse CDT Lab 3 September 12, 2010 CS-2303, System Programming Concepts, A-term 2012 Objective Laboratory Assignment #3 Eclipse CDT Due: at 11:59 pm on the day of your lab session To learn to learn to use the Eclipse

More information

CS Spring 2007 Homework #7

CS Spring 2007 Homework #7 CS 1313 010 Spring 2007 Homework #7 Quiz to be held in class 9:30-9:45am Mon March 5 2007 1. DESCRIBE THE CONDITION of an if block. ( The condition is a... ) 2. For each of these kinds of statements, mark

More information

CS : Computer Programming, Spring 2003 Programming Project #5: Sports Scores Due by 10:20am Wednesday April

CS : Computer Programming, Spring 2003 Programming Project #5: Sports Scores Due by 10:20am Wednesday April CS 1313 010: Computer Programming, Spring 2003 Programming Project #5: Sports Scores Due by 10:20am Wednesday April 9 2003 This fifth project will give you experience writing programs that involve loops

More information

COMP 110 Project 1 Programming Project Warm-Up Exercise

COMP 110 Project 1 Programming Project Warm-Up Exercise COMP 110 Project 1 Programming Project Warm-Up Exercise Creating Java Source Files Over the semester, several text editors will be suggested for students to try out. Initially, I suggest you use JGrasp,

More information

Lecture 05 I/O statements Printf, Scanf Simple statements, Compound statements

Lecture 05 I/O statements Printf, Scanf Simple statements, Compound statements Programming, Data Structures and Algorithms Prof. Shankar Balachandran Department of Computer Science and Engineering Indian Institute of Technology, Madras Lecture 05 I/O statements Printf, Scanf Simple

More information

CpSc 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 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 information

CS 1301 Exam 1 Fall 2010

CS 1301 Exam 1 Fall 2010 CS 1301 Exam 1 Fall 2010 Name : Grading TA: Integrity: By taking this exam, you pledge that this is your work and you have neither given nor received inappropriate help during the taking of this exam in

More information

CS 1044 Project 1 Fall 2011

CS 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 information

Programming for Engineers Introduction to C

Programming for Engineers Introduction to C Programming for Engineers Introduction to C ICEN 200 Spring 2018 Prof. Dola Saha 1 Simple Program 2 Comments // Fig. 2.1: fig02_01.c // A first program in C begin with //, indicating that these two lines

More information

The print queue was too long. The print queue is always too long shortly before assignments are due. Print your documentation

The print queue was too long. The print queue is always too long shortly before assignments are due. Print your documentation Chapter 1 CS488/688 F17 Assignment Format I take off marks for anything... A CS488 TA Assignments are due at the beginning of lecture on the due date specified. More precisely, all the files in your assignment

More information

The Program Specification:

The 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 information

7/8/10 KEY CONCEPTS. Problem COMP 10 EXPLORING COMPUTER SCIENCE. Algorithm. Lecture 2 Variables, Types, and Programs. Program PROBLEM SOLVING

7/8/10 KEY CONCEPTS. Problem COMP 10 EXPLORING COMPUTER SCIENCE. Algorithm. Lecture 2 Variables, Types, and Programs. Program PROBLEM SOLVING KEY CONCEPTS COMP 10 EXPLORING COMPUTER SCIENCE Lecture 2 Variables, Types, and Programs Problem Definition of task to be performed (by a computer) Algorithm A particular sequence of steps that will solve

More information

Tips from the experts: How to waste a lot of time on this assignment

Tips 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 information

2. Numbers In, Numbers Out

2. Numbers In, Numbers Out COMP1917: Computing 1 2. Numbers In, Numbers Out Reading: Moffat, Chapter 2. COMP1917 15s2 2. Numbers In, Numbers Out 1 The Art of Programming Think about the problem Write down a proposed solution Break

More information

Laboratory 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 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 information

CpSc 1011 Lab 4 Formatting and Flow Control Windchill Temps

CpSc 1011 Lab 4 Formatting and Flow Control Windchill Temps CpSc 1011 Lab 4 Formatting and Flow Control Windchill Temps Overview By the end of the lab, you will be able to: use fscanf() to accept inputs from the user and use fprint() for print statements to the

More information

Makefiles Makefiles should begin with a comment section of the following form and with the following information filled in:

Makefiles 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 information

CpSc 111 Lab 5 Conditional Statements, Loops, the Math Library, and Redirecting Input

CpSc 111 Lab 5 Conditional Statements, Loops, the Math Library, and Redirecting Input CpSc Lab 5 Conditional Statements, Loops, the Math Library, and Redirecting Input Overview For this lab, you will use: one or more of the conditional statements explained below scanf() or fscanf() to read

More information

Note : Your program must contain the following 6 functions :

Note : Your program must contain the following 6 functions : Fall 2018 - CS1428 Programming Assignment 6 Due Date : Wednesday November 7 th - 2018 Sections 3 and 4 Write a menu driven C++ program that prints the day number of the year, given the date in the form

More information

VARIABLES. Aim Understanding how computer programs store values, and how they are accessed and used in computer programs.

VARIABLES. 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 information

CS102: Variables and Expressions

CS102: 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 information

Chapter 3: Arrays and More C Functionality

Chapter 3: Arrays and More C Functionality Chapter 3: Arrays and More C Functionality Objectives: (a) Describe how an array is stored in memory. (b) Define a string, and describe how strings are stored. (c) Describe the implications of reading

More information

Program Organization and Comments

Program Organization and Comments C / C++ PROGRAMMING Program Organization and Comments Copyright 2013 Dan McElroy Programming Organization The layout of a program should be fairly straight forward and simple. Although it may just look

More information

2. Numbers In, Numbers Out

2. Numbers In, Numbers Out REGZ9280: Global Education Short Course - Engineering 2. Numbers In, Numbers Out Reading: Moffat, Chapter 2. REGZ9280 14s2 2. Numbers In, Numbers Out 1 The Art of Programming Think about the problem Write

More information

Introduction to Using OSCER s Linux Cluster Supercomputer This exercise will help you learn to use Sooner, the

Introduction to Using OSCER s Linux Cluster Supercomputer   This exercise will help you learn to use Sooner, the Introduction to Using OSCER s Linux Cluster Supercomputer http://www.oscer.ou.edu/education.php This exercise will help you learn to use Sooner, the Linux cluster supercomputer administered by the OU Supercomputing

More information

Programming Assignment #4 Arrays and Pointers

Programming Assignment #4 Arrays and Pointers CS-2301, System Programming for Non-majors, B-term 2013 Project 4 (30 points) Assigned: Tuesday, November 19, 2013 Due: Tuesday, November 26, Noon Abstract Programming Assignment #4 Arrays and Pointers

More information

Style and Submission Guide

Style and Submission Guide Style and Submission Guide 1 Assignment Style Guidelines The code you submit for assignments, as with all code you write, can be made more readable and useful by paying attention to style. This includes

More information

بسم اهلل الرمحن الرحيم

بسم اهلل الرمحن الرحيم بسم اهلل الرمحن الرحيم Fundamentals of Programming C Session # 10 By: Saeed Haratian Fall 2015 Outlines Examples Using the for Statement switch Multiple-Selection Statement do while Repetition Statement

More information

CS 051 Homework Laboratory #2

CS 051 Homework Laboratory #2 CS 051 Homework Laboratory #2 Dirty Laundry Objective: To gain experience using conditionals. The Scenario. One thing many students have to figure out for the first time when they come to college is how

More information

1. The programming language C is more than 30 years old. True or False? (Circle your choice.)

1. The programming language C is more than 30 years old. True or False? (Circle your choice.) Name: Section: Grade: Answer these questions while viewing the assigned videos. Not sure of an answer? Ask your instructor to explain at the beginning of the next class session. You can then fill in your

More information

CS 356, Fall 2018 Data Lab (Part 1): Manipulating Bits Due: Wednesday, Sep. 5, 11:59PM

CS 356, Fall 2018 Data Lab (Part 1): Manipulating Bits Due: Wednesday, Sep. 5, 11:59PM CS 356, Fall 2018 Data Lab (Part 1): Manipulating Bits Due: Wednesday, Sep. 5, 11:59PM 1 Introduction The purpose of this assignment is to become more familiar with bit-level representations of integers

More information

Parallel Programming Pre-Assignment. Setting up the Software Environment

Parallel Programming Pre-Assignment. Setting up the Software Environment Parallel Programming Pre-Assignment Setting up the Software Environment Author: B. Wilkinson Modification date: January 3, 2016 Software The purpose of this pre-assignment is to set up the software environment

More information

CS 251 Intermediate Programming Coding Standards

CS 251 Intermediate Programming Coding Standards CS 251 Intermediate Programming Coding Standards Brooke Chenoweth University of New Mexico Fall 2018 CS-251 Coding Standards All projects and labs must follow the great and hallowed CS-251 coding standards.

More information

CS16 Exam #1 7/17/ Minutes 100 Points total

CS16 Exam #1 7/17/ Minutes 100 Points total CS16 Exam #1 7/17/2012 75 Minutes 100 Points total Name: 1. (10 pts) Write the definition of a C function that takes two integers `a` and `b` as input parameters. The function returns an integer holding

More information

CS 142 Style Guide Grading and Details

CS 142 Style Guide Grading and Details 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

More information

CMSC 201 Spring 2018 Project 3 Minesweeper

CMSC 201 Spring 2018 Project 3 Minesweeper CMSC 201 Spring 2018 Project 3 Minesweeper Assignment: Project 3 Minesweeper Due Date: Design Document: Friday, May 4th, 2018 by 8:59:59 PM Project: Friday, May 11th, 2018 by 8:59:59 PM Value: 80 points

More information

Characters Lesson Outline

Characters Lesson Outline Outline 1. Outline 2. Numeric Encoding of Non-numeric Data #1 3. Numeric Encoding of Non-numeric Data #2 4. Representing Characters 5. How Characters Are Represented #1 6. How Characters Are Represented

More information

printf( Please enter another number: ); scanf( %d, &num2);

printf( Please enter another number: ); scanf( %d, &num2); CIT 593 Intro to Computer Systems Lecture #13 (11/1/12) Now that we've looked at how an assembly language program runs on a computer, we're ready to move up a level and start working with more powerful

More information

C: How to Program. Week /Mar/05

C: How to Program. Week /Mar/05 1 C: How to Program Week 2 2007/Mar/05 Chapter 2 - Introduction to C Programming 2 Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers

More information

1/25/2018. ECE 220: Computer Systems & Programming. Write Output Using printf. Use Backslash to Include Special ASCII Characters

1/25/2018. ECE 220: Computer Systems & Programming. Write Output Using printf. Use Backslash to Include Special ASCII Characters University of Illinois at Urbana-Champaign Dept. of Electrical and Computer Engineering ECE 220: Computer Systems & Programming Review: Basic I/O in C Allowing Input from the Keyboard, Output to the Monitor

More information

CpSc 1011 Lab 3 Integer Variables, Mathematical Operations, & Redirection

CpSc 1011 Lab 3 Integer Variables, Mathematical Operations, & Redirection CpSc 1011 Lab 3 Integer Variables, Mathematical Operations, & Redirection Overview By the end of the lab, you will be able to: declare variables perform basic arithmetic operations on integer variables

More information

CS Fall 2007 Homework #5

CS Fall 2007 Homework #5 CS 1313 010 Fall 2007 Homework #5 Quiz to be held in class 9:30-9:45am Mon Feb 19 2007 1. GIVE TWO EXAMPLES of unary arithmetic operations (NOT operators). 2. For the two examples of unary arithmetic operations,

More information

CMSC 201 Fall 2016 Lab 09 Advanced Debugging

CMSC 201 Fall 2016 Lab 09 Advanced Debugging CMSC 201 Fall 2016 Lab 09 Advanced Debugging Assignment: Lab 09 Advanced Debugging Due Date: During discussion Value: 10 points Part 1: Introduction to Errors Throughout this semester, we have been working

More information

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet.

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet. Mr G s Java Jive #2: Yo! Our First Program With this handout you ll write your first program, which we ll call Yo. Programs, Classes, and Objects, Oh My! People regularly refer to Java as a language that

More information

SU2017. LAB 1 (May 4/9) Introduction to C, Function Declaration vs. Definition, Basic I/O (scanf/printf, getchar/putchar)

SU2017. LAB 1 (May 4/9) Introduction to C, Function Declaration vs. Definition, Basic I/O (scanf/printf, getchar/putchar) SU2017. LAB 1 (May 4/9) Introduction to C, Function Declaration vs. Definition, Basic I/O (scanf/printf, getchar/putchar) 1 Problem A 1.1 Specification Write an ANSI-C program that reads input from the

More information

TABLE OF CONTENTS PART I: BASIC MICROSOFT WORD TOOLS... 1 PAGE BREAKS... 1 SECTION BREAKS... 3 STYLES... 6 TABLE OF CONTENTS... 8

TABLE OF CONTENTS PART I: BASIC MICROSOFT WORD TOOLS... 1 PAGE BREAKS... 1 SECTION BREAKS... 3 STYLES... 6 TABLE OF CONTENTS... 8 TABLE OF CONTENTS PART I: BASIC MICROSOFT WORD TOOLS... 1 PAGE BREAKS... 1 SECTION BREAKS... 3 STYLES... 6 TABLE OF CONTENTS... 8 LIST OF TABLES / LIST OF FIGURES... 11 PART II: FORMATTING REQUIREMENTS:

More information

c) Comments do not cause any machine language object code to be generated. d) Lengthy comments can cause poor execution-time performance.

c) Comments do not cause any machine language object code to be generated. d) Lengthy comments can cause poor execution-time performance. 2.1 Introduction (No questions.) 2.2 A Simple Program: Printing a Line of Text 2.1 Which of the following must every C program have? (a) main (b) #include (c) /* (d) 2.2 Every statement in C

More information

CS 2604 Minor Project 1 DRAFT Fall 2000

CS 2604 Minor Project 1 DRAFT Fall 2000 RPN Calculator For this project, you will design and implement a simple integer calculator, which interprets reverse Polish notation (RPN) expressions. There is no graphical interface. Calculator input

More information

Introduction to C Programming

Introduction to C Programming 1 2 Introduction to C Programming 2.6 Decision Making: Equality and Relational Operators 2 Executable statements Perform actions (calculations, input/output of data) Perform decisions - May want to print

More information

CSE / ENGR 142 Programming I

CSE / ENGR 142 Programming I CSE / ENGR 142 Programming I Variables, Values, and Types Chapter 2 Overview Chapter 2: Read Sections 2.1-2.6, 2.8. Long chapter, short snippets on many topics Later chapters fill in detail Specifically:

More information

COP 3275: Chapter 02. Jonathan C.L. Liu, Ph.D. CISE Department University of Florida, USA

COP 3275: Chapter 02. Jonathan C.L. Liu, Ph.D. CISE Department University of Florida, USA COP 3275: Chapter 02 Jonathan C.L. Liu, Ph.D. CISE Department University of Florida, USA Program: Printing a Pun #include int main(void) { printf("to C, or not to C: that is the question.\n");

More information

It is academic misconduct to share your work with others in any form including posting it on publicly accessible web sites, such as GitHub.

It is academic misconduct to share your work with others in any form including posting it on publicly accessible web sites, such as GitHub. p4: Cache Simulator 1. Logistics 1. This project must be done individually. It is academic misconduct to share your work with others in any form including posting it on publicly accessible web sites, such

More information

Lab 1 Introduction to UNIX and C

Lab 1 Introduction to UNIX and C Name: Lab 1 Introduction to UNIX and C This first lab is meant to be an introduction to computer environments we will be using this term. You must have a Pitt username to complete this lab. The doc is

More information

Full file at

Full 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 information

M.CS201 Programming language

M.CS201 Programming language Power Engineering School M.CS201 Programming language Lecture 4 Lecturer: Prof. Dr. T.Uranchimeg Agenda How a Function Works Function Prototype Structured Programming Local Variables Return value 2 Function

More information

Lab # 02. Basic Elements of C++ _ Part1

Lab # 02. Basic Elements of C++ _ Part1 Lab # 02 Basic Elements of C++ _ Part1 Lab Objectives: After performing this lab, the students should be able to: Become familiar with the basic components of a C++ program, including functions, special

More information

CSE 11 Style Guidelines

CSE 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 information

FALL 2017 CSCI 304 LAB1 (Due on Sep-19, 11:59:59pm)

FALL 2017 CSCI 304 LAB1 (Due on Sep-19, 11:59:59pm) FALL 2017 CSCI 304 LAB1 (Due on Sep-19, 11:59:59pm) Objectives: Debugger Standard I/O Arithmetic statements Conditional structures Looping structures File I/O Strings Pointers Functions Structures Important

More information

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved.

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved. C How to Program, 6/e 1992-2010 by Pearson Education, Inc. 1992-2010 by Pearson Education, Inc. 1992-2010 by Pearson Education, Inc. This chapter serves as an introduction to the important topic of data

More information

Data Types and Variables in C language

Data Types and Variables in C language Data Types and Variables in C language Basic structure of C programming To write a C program, we first create functions and then put them together. A C program may contain one or more sections. They are

More information

EC312 Chapter 4: Arrays and Strings

EC312 Chapter 4: Arrays and Strings Objectives: (a) Describe how an array is stored in memory. (b) Define a string, and describe how strings are stored. EC312 Chapter 4: Arrays and Strings (c) Describe the implications of reading or writing

More information

Intro to Computer Programming (ICP) Rab Nawaz Jadoon

Intro to Computer Programming (ICP) Rab Nawaz Jadoon Intro to Computer Programming (ICP) Rab Nawaz Jadoon DCS COMSATS Institute of Information Technology Assistant Professor COMSATS IIT, Abbottabad Pakistan Introduction to Computer Programming (ICP) What

More information

CS1 Lecture 3 Jan. 18, 2019

CS1 Lecture 3 Jan. 18, 2019 CS1 Lecture 3 Jan. 18, 2019 Office hours for Prof. Cremer and for TAs have been posted. Locations will change check class website regularly First homework assignment will be available Monday evening, due

More information

BIL 104E Introduction to Scientific and Engineering Computing. Lecture 1

BIL 104E Introduction to Scientific and Engineering Computing. Lecture 1 BIL 104E Introduction to Scientific and Engineering Computing Lecture 1 Introduction As engineers and scientists why do we need computers? We use computers to solve a variety of problems ranging from evaluation

More information

Programming Style Guide v1.1

Programming Style Guide v1.1 Oregon State University Intro to programming Source Code Style Guide Modified from: OREGON INSTITUTE OF TECHNOLOGY COMPUTER SYSTEMS ENGINEERING TECHNOLOGY Modified by: Joseph Jess Programming Style Guide

More information

Arithmetic Expressions Lesson #1 Outline

Arithmetic Expressions Lesson #1 Outline Outline 1. Outline 2. A Less Simple C Program #1 3. A Less Simple C Program #2 4. A Less Simple C Program #3 5. A Less Simple C Program #4 6. A Less Simple C Program: Compile & Run 7. Flowchart for my_add.c

More information

Introduction to C Programming. What is a C program?

Introduction to C Programming. What is a C program? Introduction to C Programming Goals of this section Write a simple C program - Steps Write or develop code Compile Link Execute Add comments to C code 85-132 Introduction to C-Programming 2-1 What is a

More information

Use of scanf. scanf("%d", &number);

Use of scanf. scanf(%d, &number); Use of scanf We have now discussed how to print out formatted information to the screen, but this isn't nearly as useful unless we can read in information from the user. (This is one way we can make a

More information

CS113: Lecture 3. Topics: Variables. Data types. Arithmetic and Bitwise Operators. Order of Evaluation

CS113: Lecture 3. Topics: Variables. Data types. Arithmetic and Bitwise Operators. Order of Evaluation CS113: Lecture 3 Topics: Variables Data types Arithmetic and Bitwise Operators Order of Evaluation 1 Variables Names of variables: Composed of letters, digits, and the underscore ( ) character. (NO spaces;

More information

Chapter 11 Introduction to Programming in C

Chapter 11 Introduction to Programming in C Chapter 11 Introduction to Programming in C C: A High-Level Language Gives symbolic names to values don t need to know which register or memory location Provides abstraction of underlying hardware operations

More information

ECEn 424 Data Lab: Manipulating Bits

ECEn 424 Data Lab: Manipulating Bits ECEn 424 Data Lab: Manipulating Bits 1 Introduction The purpose of this assignment is to become more familiar with bit-level representations of integers and floating point numbers. You ll do this by solving

More information