Project 1: How to Make One Dollar

Size: px
Start display at page:

Download "Project 1: How to Make One Dollar"

Transcription

1 Project Objective: Project 1: How to Make One Dollar Posted: Wednesday February 16, Described: Thursday February 17, Due: 11:59PM, Sunday March 6, get familiar with the process of completing a programming project. 2. learn the basics of printf( ) and scanf(). 3. declare and use of variables of the basic data types. 4. use basic relational and logical operators. 5. use basic if and/or if-else statements for program selection. 6. use array and basic loops (while, do-while, for) for repetition. 7. command line argument 8. read from and write into a file Project Description: In this project, you will design and implement an algorithm (method) to make one dollar from a given set of coins including quarters, dimes, nickels, and pennies. For example, if you have five quarters, five dimes, five nickels, and five pennies ( in short), one possible combination to make one dollar is to use one quarter, five dimes, four nickels, and five pennies ( in short) and are two other possible combinations is not a solution as it makes $ makes one dollar but it is not a solution either because you have only five dimes. Your program should read in the number of coins from an input file, determine all the possible ways to make one dollar by using only these coins, and write them into an output file in a tabular format. Your program should also find the way to make one dollar with the minimum number of coins and write it both to the output file and to the monitor. A master program, in the format of executable file, and a sample input file will be provided. Input Your program will read in input from a file of multiple lines. Each line consists of exactly four numbers representing the numbers of quarters, dimes, nickel, and pennies, respectively. These four numbers are separated by a single white space. For example, is a file that has three sets of coins. The first set has one quarter, two dimes, three nickels, and four pennies; the second set has one quarter, two dimes, four nickels, and four pennies; and the last set has five of each.

2 Output This project requires you write your output both to an output file and to the monitor. For each line of the input file, your program should write the following into an output file 1. the first line is a header line in the format of *************************Line ##************************* where ## represents the line number, starting from 1, of the input file. - Give two spaces for this field to allow your program to handle up to 99 lines of input. - Make the ## right aligned. - There are 25 stars (*)to each side of the phrase Line ##. - There is one space between the word Line and the line number ##. However, you will see two spaces when the line number ## is a single digit. 2. the second line is a description on the given coin set We have x quarters, y dimes, z nickels, and w pennies. where x, y, z, and w should be replaced by the numbers that you read in from the input file. - Use exactly one white space to separate the words. - Make sure that you use quarters (dimes, nickels, pennies) when there are 2 or more coins of that kind and use quarter (dime, nickel, penny) otherwise. 3. the third line is the header of the tabular output for all the ways to make one dollar index Q D N P Total These words are separated by three white spaces, except P and Total which are separated by five white spaces. 4. the next will be the actual ways to make one dollar, for example The first number represents the index and starts from 1. - The next four numbers represent the number of each coin. - The last number is the total number of coins used in this solution. - All the numbers are right aligned with the last letter of their corresponding words in the header of the table (index Q D N P Total).

3 5. the last two lines print out the total number of solutions and the best combination in the following format There are k different ways to make one dollar. Best solution: x quarters and y dimes and z nickels and w pennies and a total of v coins. where v = x+y+z+w. - k should be the same as the largest index in the above table. When k=1, print out There is 1 way to make one dollar. Best solution: x quarters and y dimes and z nickels and w pennies and a total of v coins. - Print out the word quarters (dimes, nickels, pennies) only if x (y, z, w) is greater than or equal to 1. For example, in the last solution give above, print out - Use quarter (dime, nickel, penny) instead if x (y,z,w) equals if you cannot make one dollar from the given set of coins, replace the items 3-5 by the following sentence In addition, print out the above items 1, 2, 5 (or 6, depending on the program output) onto the computer monitor. For example, give the above sample input file, you should write to an output file *************************Line 1************************* We have 1 quarter, 2 dimes, 3 nickels, and 4 pennies. *************************Line 2************************* We have 1 quarter, 2 dimes, 4 nickels, and 4 pennies. *************************Line 3************************* We have 5 quarters, 5 dimes, 5 nickels, and 5 pennies. index Q D N P Total

4 There are 15 different ways to make one dollar. Meanwhile, print out the following to the computer monitor *************************Line 1************************* We have 1 quarter, 2 dimes, 3 nickels, and 4 pennies. *************************Line 2************************* We have 1 quarter, 2 dimes, 4 nickels, and 4 pennies. *************************Line 3************************* We have 5 quarters, 5 dimes, 5 nickels, and 5 pennies. There are 15 different ways to make one dollar. Project Requirements: 1. You must program using C under GLUE UNIX system and name your program p1.c. 2. Your program must be properly documented. 3. Submit your program p1.c electronically before the due time. How to do this will be discussed in the recitation sections. 4. IMPORTANT: Your program s output, both to the output file and to the computer monitor, should be exactly the same as that produced by the master program. The only exception is that in the tabular output of all the combinations to make one dollar, the order of those combinations can be different from the master program. Grading Criteria: Correctness: 80% Good coding style: 10% Proper documentation: 10% Late submission penalty: -40% for the first 24 hours No submission will be accepted after the first 24 hours.

5 Project Template: (only for your reference, you do not have to use this) // document your project and write down your name, student ID, // section No. here #include <stdio.h> // define constants and functions if you are using them int main(int argc, char *argv[]) { // declare the input and output files FILE* input, *output; // declare other variables // some safety check if(argc!=3) { printf("usage: exectuable inputfile outputfile\n"); exit(0); // open the input and output files with more safety check input = fopen(argv[1],"r"); if( input == NULL) { printf("file %s cannot open!\n", argv[1]); output = fopen(argv[2], "w"); if( output == NULL) { printf("file %s cannot open!\n", argv[2]); // write your code here // close the input and output files fclose(input); fclose(ouput); return 0;

Lab Exam 1 D [1 mark] Give an example of a sample input which would make the function

Lab Exam 1 D [1 mark] Give an example of a sample input which would make the function CMPT 127 Spring 2019 Grade: / 20 First name: Last name: Student Number: Lab Exam 1 D400 1. [1 mark] Give an example of a sample input which would make the function scanf( "%f", &f ) return -1? Answer:

More information

King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department

King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department CPCS202, 1 st Term 2016 (Fall 2015) Program 5: FCIT Grade Management System Assigned: Thursday, December

More information

COMP 2355 Introduction to Systems Programming

COMP 2355 Introduction to Systems Programming COMP 2355 Introduction to Systems Programming Christian Grothoff christian@grothoff.org http://grothoff.org/christian/ 1 Functions Similar to (static) methods in Java without the class: int f(int a, int

More information

Lab Exam 1 D [1 mark] Give an example of a sample input which would make the function

Lab Exam 1 D [1 mark] Give an example of a sample input which would make the function Grade: / 20 Lab Exam 1 D500 1. [1 mark] Give an example of a sample input which would make the function scanf( "%f", &f ) return 0? Answer: Anything that is not a floating point number such as 4.567 or

More information

Prerequisites: Read all chapters through Chapter 4 in the textbook before attempting this lab. Read through this entire assignment before you begin.

Prerequisites: Read all chapters through Chapter 4 in the textbook before attempting this lab. Read through this entire assignment before you begin. Assignment Number 5 Lab Assignment Due Date: Wednesday, October 3, 2018 LAB QUESTIONS Due Date: Email before Monday, October 8, 2018 before 5:00 PM CS 1057 C Programming - Fall 2018 Purpose: write a complete

More information

Each line will contain a string ("even" or "odd"), followed by one or more spaces, followed by a nonnegative integer.

Each line will contain a string (even or odd), followed by one or more spaces, followed by a nonnegative integer. Decision-making in C Squeezing Digits out of an Integer Assignment For part of this assignment, you will use very basic C techniques to implement a C function to remove from a given nonnegative integer

More information

CSE 303 Lecture 8. Intro to C programming

CSE 303 Lecture 8. Intro to C programming CSE 303 Lecture 8 Intro to C programming read C Reference Manual pp. Ch. 1, 2.2-2.4, 2.6, 3.1, 5.1, 7.1-7.2, 7.5.1-7.5.4, 7.6-7.9, Ch. 8; Programming in C Ch. 1-6 slides created by Marty Stepp http://www.cs.washington.edu/303/

More information

Today s Learning Objectives

Today s Learning Objectives Today s Learning Objectives 15-123 Systems Skills in C and Unix We will Review ints and modular arithmetic Learn basic Data types and Formats How Conditionals and loops work How Arrays are defined, accessed,

More information

Project#3 [40 points] COP 2220 Fall 2017

Project#3 [40 points] COP 2220 Fall 2017 Project#3 [40 points] COP 2220 Fall 2017 (Materials that you MUST review for this project) 2017 Saeed Rajput, Ph.D. Problem Requirements: Allow students to submit assignments and instructor to award grades

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

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 Operating Systems Lab 3: UNIX Processes

CS Operating Systems Lab 3: UNIX Processes CS 346 - Operating Systems Lab 3: UNIX Processes Due: February 15 Purpose: In this lab you will become familiar with UNIX processes. In particular you will examine processes with the ps command and terminate

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

ECE 264 Exam 2. 6:30-7:30PM, March 9, You must sign here. Otherwise you will receive a 1-point penalty.

ECE 264 Exam 2. 6:30-7:30PM, March 9, You must sign here. Otherwise you will receive a 1-point penalty. ECE 264 Exam 2 6:30-7:30PM, March 9, 2011 I certify that I will not receive nor provide aid to any other student for this exam. Signature: You must sign here. Otherwise you will receive a 1-point penalty.

More information

CS16 Midterm Exam 1 E01, 10S, Phill Conrad, UC Santa Barbara Wednesday, 04/21/2010, 1pm-1:50pm

CS16 Midterm Exam 1 E01, 10S, Phill Conrad, UC Santa Barbara Wednesday, 04/21/2010, 1pm-1:50pm CS16 Midterm Exam 1 E01, 10S, Phill Conrad, UC Santa Barbara Wednesday, 04/21/2010, 1pm-1:50pm Name: Umail Address: @ umail.ucsb.edu Circle Lab section: 9am 10am 11am noon (Link to Printer Friendly-PDF

More information

Lab 6B Coin Collection

Lab 6B Coin Collection HNHS Computer Programming I / IPFW CS 11400 Bower - Page 1 Lab 6B Coin Collection You will create a program that allows users to enter the quantities of an assortment of coins (quarters, dimes, nickels,

More information

Lecture 7: Files. opening/closing files reading/writing strings reading/writing numbers (conversion to ASCII) command line arguments

Lecture 7: Files. opening/closing files reading/writing strings reading/writing numbers (conversion to ASCII) command line arguments Lecture 7: Files opening/closing files reading/writing strings reading/writing numbers (conversion to ASCII) command line arguments Lecture 5: Files, I/O 0IGXYVI*MPIW 0 opening/closing files reading/writing

More information

are all acceptable. With the right compiler flags, Java/C++ style comments are also acceptable.

are all acceptable. With the right compiler flags, Java/C++ style comments are also acceptable. CMPS 12M Introduction to Data Structures Lab Lab Assignment 3 The purpose of this lab assignment is to introduce the C programming language, including standard input-output functions, command line arguments,

More information

Binghamton University. CS-211 Fall Variable Scope

Binghamton University. CS-211 Fall Variable Scope Variable Scope 1 2 Scope The places in your code that can read and/or write a variable. Scope starts at the location where you declare the variable There may be holes in the scope! Scope ends at the end

More information

CS261: HOMEWORK 2 Due 04/13/2012, at 2pm

CS261: HOMEWORK 2 Due 04/13/2012, at 2pm CS261: HOMEWORK 2 Due 04/13/2012, at 2pm Submit six *.c files via the TEACH website: https://secure.engr.oregonstate.edu:8000/teach.php?type=want_auth 1. Introduction The purpose of HW2 is to help you

More information

Programming in C First meeting

Programming in C First meeting Programming in C First meeting 8.9.2016 Tiina Niklander Faculty of Science Department of Computer Science www.cs.helsinki.fi 8.9.2016 1 Course structure Weekly exercise deadline on Wednesday, lectures

More information

King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department

King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department CPCS204, 2 nd Term 2014 Program 2: KAU Grade Book (Linked Lists) Assigned: Thursday, February 20 th,

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

UNIVERSITY OF NEBRASKA AT OMAHA Computer Science 4500/8506 Operating Systems Fall Programming Assignment 1 (updated 9/16/2017)

UNIVERSITY OF NEBRASKA AT OMAHA Computer Science 4500/8506 Operating Systems Fall Programming Assignment 1 (updated 9/16/2017) UNIVERSITY OF NEBRASKA AT OMAHA Computer Science 4500/8506 Operating Systems Fall 2017 Programming Assignment 1 (updated 9/16/2017) Introduction The purpose of this programming assignment is to give you

More information

Marking rubric for Assignment #2

Marking rubric for Assignment #2 Marking rubric for Assignment #2 The TAs marked the following sections: Yu: Section A Questions -4, Section B Questions -3 Megan: Section B Questions 4-5 Assignment #2 Marking Rubric: A. WriteUp Please

More information

CSE331 Winter 2014, Midterm Examination February 12, 2014

CSE331 Winter 2014, Midterm Examination February 12, 2014 CSE331 Winter 2014, Midterm Examination February 12, 2014 Please do not turn the page until 10:30. Rules: The exam is closed-book, closed-note, etc. Please stop promptly at 11:20. There are 100 points

More information

Unit 6 Files. putchar(ch); ch = getc (fp); //Reads single character from file and advances position to next character

Unit 6 Files. putchar(ch); ch = getc (fp); //Reads single character from file and advances position to next character 1. What is File management? In real life, we want to store data permanently so that later on we can retrieve it and reuse it. A file is a collection of bytes stored on a secondary storage device like hard

More information

Problem Set 1: Unix Commands 1

Problem Set 1: Unix Commands 1 Problem Set 1: Unix Commands 1 WARNING: IF YOU DO NOT FIND THIS PROBLEM SET TRIVIAL, I WOULD NOT RECOMMEND YOU TAKE THIS OFFERING OF 300 AS YOU DO NOT POSSESS THE REQUISITE BACKGROUND TO PASS THE COURSE.

More information

Worksheet 4 Basic Input functions and Mathematical Operators

Worksheet 4 Basic Input functions and Mathematical Operators Name: Student ID: Date: Worksheet 4 Basic Input functions and Mathematical Operators Objectives After completing this worksheet, you should be able to Use an input function in C Declare variables with

More information

Array Initialization

Array Initialization Array Initialization Array declarations can specify initializations for the elements of the array: int primes[10] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29 ; initializes primes[0] to 2, primes[1] to 3, primes[2]

More information

CSE331 Winter 2014, Midterm Examination February 12, 2014

CSE331 Winter 2014, Midterm Examination February 12, 2014 CSE331 Winter 2014, Midterm Examination February 12, 2014 Please do not turn the page until 10:30. Rules: The exam is closed-book, closed-note, etc. Please stop promptly at 11:20. There are 100 points

More information

Name Section: M/W T/TH Number Definition Matching (6 Points)

Name Section: M/W T/TH Number Definition Matching (6 Points) Name Section: M/W T/TH Number Definition Matching (6 Points) 1. (6 pts) Match the words with their definitions. Choose the best definition for each word. Event Counter Iteration Counter Loop Flow of Control

More information

SU 2017 May 11/16 LAB 2: Character and integer literals, number systems, character arrays manipulation, relational operator

SU 2017 May 11/16 LAB 2: Character and integer literals, number systems, character arrays manipulation, relational operator SU 2017 May 11/16 LAB 2: Character and integer literals, number systems, character arrays manipulation, relational operator 0 Problem 0 number bases Visit the website www.cleavebooks.co.uk/scol/calnumba.htm

More information

Floating-point lab deadline moved until Wednesday Today: characters, strings, scanf Characters, strings, scanf questions clicker questions

Floating-point lab deadline moved until Wednesday Today: characters, strings, scanf Characters, strings, scanf questions clicker questions Announcements Thursday Extras: CS Commons on Thursdays @ 4:00 pm but none next week No office hours next week Monday or Tuesday Reflections: when to use if/switch statements for/while statements Floating-point

More information

Introduction to OS Processes in Unix, Linux, and Windows MOS 2.1 Mahmoud El-Gayyar

Introduction to OS Processes in Unix, Linux, and Windows MOS 2.1 Mahmoud El-Gayyar Introduction to OS Processes in Unix, Linux, and Windows MOS 2.1 Mahmoud El-Gayyar elgayyar@ci.suez.edu.eg Mahmoud El-Gayyar / Introduction to OS 1 Processes in Unix, Linux, and Windows Unix pre-empted

More information

Instructions PLEASE READ (notice bold and underlined phrases)

Instructions PLEASE READ (notice bold and underlined phrases) Assignment 2 Writing Basic Java Programs Required Reading Java Foundations Chapter 2 Data and Expressions Chapter 3 Sections 3.1-3.2, 3.4-3.7 Chapter 4 Sections 4.2-4.5, 4.7-4.8 Instructions PLEASE READ

More information

Hello, World! in C. Johann Myrkraverk Oskarsson October 23, The Quintessential Example Program 1. I Printing Text 2. II The Main Function 3

Hello, World! in C. Johann Myrkraverk Oskarsson October 23, The Quintessential Example Program 1. I Printing Text 2. II The Main Function 3 Hello, World! in C Johann Myrkraverk Oskarsson October 23, 2018 Contents 1 The Quintessential Example Program 1 I Printing Text 2 II The Main Function 3 III The Header Files 4 IV Compiling and Running

More information

Recitation 2/18/2012

Recitation 2/18/2012 15-213 Recitation 2/18/2012 Announcements Buflab due tomorrow Cachelab out tomorrow Any questions? Outline Cachelab preview Useful C functions for cachelab Cachelab Part 1: you have to create a cache simulator

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

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

BIL 104E Introduction to Scientific and Engineering Computing. Lecture 14 BIL 104E Introduction to Scientific and Engineering Computing Lecture 14 Because each C program starts at its main() function, information is usually passed to the main() function via command-line arguments.

More information

Why C++ is much more fun than C (C++ FAQ)?

Why C++ is much more fun than C (C++ FAQ)? From C to C++ Why C++ is much more fun than C (C++ FAQ)? 1. Classes & methods - OO design 2. Generic programming - Templates allow for code reuse 3. Stricter type system (e.g. function args) 4. Some run-time

More information

Math in Focus Vocabulary. Kindergarten

Math in Focus Vocabulary. Kindergarten Math in Focus Vocabulary Kindergarten Chapter Word Definition 1 one 1 * 1 two 2 * * 1 three 3 * * * 1 four 4 * * * * 1 five 5 * * * * * 1 same things that have a common property 1 different things that

More information

Lecture 2: C Programming Basic

Lecture 2: C Programming Basic ECE342 Introduction to Embedded Systems Lecture 2: C Programming Basic Ying Tang Electrical and Computer Engineering Rowan University 1 Facts about C C was developed in 1972 in order to write the UNIX

More information

Darshan Institute of Engineering & Technology for Diploma Studies Unit 6

Darshan Institute of Engineering & Technology for Diploma Studies Unit 6 1. What is File management? In real life, we want to store data permanently so that later on we can retrieve it and reuse it. A file is a collection of bytes stored on a secondary storage device like hard

More information

UNIVERSITY OF WINDSOR Winter 2007 QUIZ # 1 Solution. Examiner:Ritu Chaturvedi Dated : Feb 7 th, Student Name: Student Number:

UNIVERSITY OF WINDSOR Winter 2007 QUIZ # 1 Solution. Examiner:Ritu Chaturvedi Dated : Feb 7 th, Student Name: Student Number: UNIVERSITY OF WINDSOR 60-106-01 Winter 2007 QUIZ # 1 Solution Examiner:Ritu Chaturvedi Dated : Feb 7 th, 2007. Student Name: Student Number: INSTRUCTIONS (Please Read Carefully) No calculators allowed.

More information

CS 2316 Individual Homework 1 Python Practice Due: Wednesday, August 28th, before 11:55 PM Out of 100 points

CS 2316 Individual Homework 1 Python Practice Due: Wednesday, August 28th, before 11:55 PM Out of 100 points CS 2316 Individual Homework 1 Python Practice Due: Wednesday, August 28th, before 11:55 PM Out of 100 points Files to submit: 1. HW1.py For Help: - TA Helpdesk Schedule posted on class website. - Email

More information

Reading Assignment 4. n Chapter 4 Threads, due 2/7. 1/31/13 CSE325 - Processes 1

Reading Assignment 4. n Chapter 4 Threads, due 2/7. 1/31/13 CSE325 - Processes 1 Reading Assignment 4 Chapter 4 Threads, due 2/7 1/31/13 CSE325 - Processes 1 What s Next? 1. Process Concept 2. Process Manager Responsibilities 3. Operations on Processes 4. Process Scheduling 5. Cooperating

More information

ch = argv[i][++j]; /* why does ++j but j++ does not? */

ch = argv[i][++j]; /* why does ++j but j++ does not? */ CMPS 12M Introduction to Data Structures Lab Lab Assignment 4 The purpose of this lab assignment is to get more practice programming in C, including the character functions in the library ctype.h, and

More information

COMP2521. Generic ADTs in C

COMP2521. Generic ADTs in C COMP2521 Generic ADTs in C 1 Function Pointers C can pass functions by passing a pointer to them. Function pointers... are references to memory addresses of functions are pointer values and can be assigned/passed

More information

Midterm Examination # 2 Wednesday, March 19, Duration of examination: 75 minutes STUDENT NAME: STUDENT ID NUMBER:

Midterm Examination # 2 Wednesday, March 19, Duration of examination: 75 minutes STUDENT NAME: STUDENT ID NUMBER: Page 1 of 7 School of Computer Science 60-141-01 Introduction to Algorithms and Programming Winter 2014 Midterm Examination # 2 Wednesday, March 19, 2014 ANSWERS Duration of examination: 75 minutes STUDENT

More information

ECE264 Spring 2013 Exam 1, February 14, 2013

ECE264 Spring 2013 Exam 1, February 14, 2013 ECE264 Spring 2013 Exam 1, February 14, 2013 In signing this statement, I hereby certify that the work on this exam is my own and that I have not copied the work of any other student while completing it.

More information

Friday, February 10, Lab Notes

Friday, February 10, Lab Notes Friday, February 10, 2017 Lab Notes Topics for today Structures in C Redirection of input and output in a Unix-like environment Command line arguments More pre-processor options Programs: Finish Program

More information

Memory. What is memory? How is memory organized? Storage for variables, data, code etc. Text (Code) Data (Constants) BSS (Global and static variables)

Memory. What is memory? How is memory organized? Storage for variables, data, code etc. Text (Code) Data (Constants) BSS (Global and static variables) Memory Allocation Memory What is memory? Storage for variables, data, code etc. How is memory organized? Text (Code) Data (Constants) BSS (Global and static variables) Text Data BSS Heap Stack (Local variables)

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

File Handling. 21 July 2009 Programming and Data Structure 1

File Handling. 21 July 2009 Programming and Data Structure 1 File Handling 21 July 2009 Programming and Data Structure 1 File handling in C In C we use FILE * to represent a pointer to a file. fopen is used to open a file. It returns the special value NULL to indicate

More information

C Language Coding Standard

C Language Coding Standard C Language Coding Standard For CS1003, CS1013, and CS2635 Rick Wightman Faculty of Computer Science University of New Brunswick Fredericton, NB January, 2001 INTRODUCTION Programming is a craft. Skill

More information

Midterm Exam 2 Solutions C Programming Dr. Beeson, Spring 2009

Midterm Exam 2 Solutions C Programming Dr. Beeson, Spring 2009 Midterm Exam 2 Solutions C Programming Dr. Beeson, Spring 2009 April 16, 2009 Instructions: Please write your answers on the printed exam. Do not turn in any extra pages. No interactive electronic devices

More information

Computer Science & Information Technology (CS) Rank under AIR 100. Examination Oriented Theory, Practice Set Key concepts, Analysis & Summary

Computer Science & Information Technology (CS) Rank under AIR 100. Examination Oriented Theory, Practice Set Key concepts, Analysis & Summary GATE- 2016-17 Postal Correspondence 1 C-Programming Computer Science & Information Technology (CS) 20 Rank under AIR 100 Postal Correspondence Examination Oriented Theory, Practice Set Key concepts, Analysis

More information

2009 S2 COMP File Operations

2009 S2 COMP File Operations 2009 S2 COMP1921 9. File Operations Oliver Diessel odiessel@cse.unsw.edu.au Last updated: 16:00 22 Sep 2009 9. File Operations Topics to be covered: Streams Text file operations Binary file operations

More information

pset1: C Tommy MacWilliam Grading Getting Started pset1: C Style Pennies Greedy Chart September 11, 2011

pset1: C Tommy MacWilliam Grading Getting Started pset1: C Style Pennies Greedy Chart September 11, 2011 tmacwilliam@cs50.net September 11, 2011 Today s Music 3OH!3 Deja Vu Hey See you Go Streets of Gold Axes scope: does it have everything? correctness: does it work? design: how efficiently does it work,

More information

First C or C++ Lab Paycheck-V1.0 Using Microsoft Visual Studio

First C or C++ Lab Paycheck-V1.0 Using Microsoft Visual Studio C & C++ LAB ASSIGNMENT #1 First C or C++ Lab Paycheck-V1.0 Using Microsoft Visual Studio Copyright 2013 Dan McElroy Paycheck-V1.0 The purpose of this lab assignment is to enter a C or C++ into Visual Studio

More information

File IO and command line input CSE 2451

File IO and command line input CSE 2451 File IO and command line input CSE 2451 File functions Open/Close files fopen() open a stream for a file fclose() closes a stream One character at a time: fgetc() similar to getchar() fputc() similar to

More information

Friday, September 16, Lab Notes. Command line arguments More pre-processor options Programs: Finish Program 1, begin Program 2 due next week

Friday, September 16, Lab Notes. Command line arguments More pre-processor options Programs: Finish Program 1, begin Program 2 due next week Friday, September 16, 2016 Lab Notes Topics for today Redirection of input and output Command line arguments More pre-processor options Programs: Finish Program 1, begin Program 2 due next week 1. Redirection

More information

Algorithms & Programming. Midterm Examination # 2. Student Name: Student ID Number: Duration of examination:

Algorithms & Programming. Midterm Examination # 2. Student Name: Student ID Number: Duration of examination: School of Computer Science 60-141-01 Algorithms & Programming Winter 2007 Midterm Examination # 2 Wednesday, March 21, 2007 Student Name: First Name Family Name Student ID Number: Duration of examination:

More information

Programming in C week 1 meeting Tiina Niklander

Programming in C week 1 meeting Tiina Niklander Programming in C week 1 meeting 2.9.2015 Tiina Niklander Faculty of Science Department of Computer Science 3.9.2015 1 Course structure Based on C programming course in Aalto, but with some exercises created

More information

Name Section: M/W T/TH Number Definition Matching (8 Points)

Name Section: M/W T/TH Number Definition Matching (8 Points) Name Section: M/W T/TH Number Definition Matching (8 Points) 1. (8 pts) Match the words with their definitions. Choose the best definition for each word. Iteration Counter Event Counter Loop Abstract Step

More information

CSE 374 Programming Concepts & Tools

CSE 374 Programming Concepts & Tools CSE 374 Programming Concepts & Tools Hal Perkins Fall 2017 Lecture 8 C: Miscellanea Control, Declarations, Preprocessor, printf/scanf 1 The story so far The low-level execution model of a process (one

More information

Programming in C. Pointers and Arrays

Programming in C. Pointers and Arrays Programming in C Pointers and Arrays NEXT SET OF SLIDES FROM DENNIS FREY S FALL 2011 CMSC313 http://www.csee.umbc.edu/courses/undergraduate/313/fall11/" Pointers and Arrays In C, there is a strong relationship

More information

COP Programming Concepts Spring 1999 CLOSED BOOK Exam #1 100 Points NAME

COP Programming Concepts Spring 1999 CLOSED BOOK Exam #1 100 Points NAME CLOSED BOOK Exam #1 100 Points NAME 1. The following program has (at least) 10 syntax errors. Circle each error. Write the corrected program in the blank space below. 2 points for each error you find.

More information

PROGRAMMAZIONE I A.A. 2017/2018

PROGRAMMAZIONE I A.A. 2017/2018 PROGRAMMAZIONE I A.A. 2017/2018 FUNCTIONS INTRODUCTION AND MAIN All the instructions of a C program are contained in functions. üc is a procedural language üeach function performs a certain task A special

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

SPRING 2017 CSCI 304 LAB1 (Due on Feb-14, 11:59:59pm)

SPRING 2017 CSCI 304 LAB1 (Due on Feb-14, 11:59:59pm) SPRING 2017 CSCI 304 LAB1 (Due on Feb-14, 11:59:59pm) Objectives: Debugger Standard I/O Arithmetic statements IF/Switch structures Looping structures File I/O Strings Pointers Functions Structures Important

More information

EECE.2160: ECE Application Programming Spring 2017

EECE.2160: ECE Application Programming Spring 2017 Course Meetings Section 201: MWF 8-8:50, Ball 314 Section 202: MWF 12-12:50, Kitson 305 Course Website Main page: http://mjgeiger.github.io/eece2160/sp17/ Schedule: http://mjgeiger.github.io/eece2160/sp17/schedule.htm

More information

Programming and Data Structure

Programming and Data Structure Programming and Data Structure Sujoy Ghose Sudeshna Sarkar Jayanta Mukhopadhyay Dept. of Computer Science & Engineering. Indian Institute of Technology Kharagpur Spring Semester 2012 Programming and Data

More information

Use the scantron sheet to enter the answer to questions (pages 1-6)

Use the scantron sheet to enter the answer to questions (pages 1-6) Use the scantron sheet to enter the answer to questions 1-100 (pages 1-6) Part I. Mark A for True, B for false. (1 point each) 1. Abstraction allow us to specify an object regardless of how the object

More information

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14 C introduction Variables Variables 1 / 14 Contents Variables Data types Variable I/O Variables 2 / 14 Usage Declaration: t y p e i d e n t i f i e r ; Assignment: i d e n t i f i e r = v a l u e ; Definition

More information

2 2

2 2 1 2 2 3 3 C:\Temp\Templates 4 5 Use This Main Program 6 # include "Utilities.hpp" # include "Student.hpp" Copy/Paste Main void MySwap (int Value1, int Value2); int main(int argc, char * argv[]) { int A

More information

Summary of Last Class. Processes. C vs. Java. C vs. Java (cont.) C vs. Java (cont.) Tevfik Ko!ar. CSC Systems Programming Fall 2008

Summary of Last Class. Processes. C vs. Java. C vs. Java (cont.) C vs. Java (cont.) Tevfik Ko!ar. CSC Systems Programming Fall 2008 CSC 4304 - Systems Programming Fall 2008 Lecture - II Basics of C Programming Summary of Last Class Basics of UNIX: logging in, changing password text editing with vi, emacs and pico file and director

More information

CSC 1107: Structured Programming

CSC 1107: Structured Programming CSC 1107: Structured Programming J. Kizito Makerere University e-mail: www: materials: e-learning environment: office: alt. office: jkizito@cis.mak.ac.ug http://serval.ug/~jona http://serval.ug/~jona/materials/csc1107

More information

ECE 2035 Programming HW/SW Systems Spring problems, 7 pages Exam One Solutions 4 February 2013

ECE 2035 Programming HW/SW Systems Spring problems, 7 pages Exam One Solutions 4 February 2013 Problem 1 (3 parts, 30 points) Code Fragments Part A (5 points) Write a MIPS code fragment that branches to label Target when register $1 is less than or equal to register $2. You may use only two instructions.

More information

Design and Analysis of Computer Algorithms

Design and Analysis of Computer Algorithms Design and Analysis of Computer Algorithms Homework #1: Due 21 March 2018 (Wednesday). Just before class! Problem #1 (30 points). Programming Shopping is FUN Kang Ji Sung very loves shopping. Whenever

More information

CSC 1107: Structured Programming

CSC 1107: Structured Programming CSC 1107: Structured Programming J. Kizito Makerere University e-mail: www: materials: e-learning environment: office: jkizito@cis.mak.ac.ug http://serval.ug/~jona http://serval.ug/~jona/materials/csc1107

More information

CS 210 Fundamentals of Programming I Spring 2015 Programming Assignment 4

CS 210 Fundamentals of Programming I Spring 2015 Programming Assignment 4 CS 210 Fundamentals of Programming I Spring 2015 Programming Assignment 4 20 points Out: February 18/19, 2015 Due: February 25/26, 2015 Reminder: This is a programming assignment, and work on this assignment

More information

Approximately a Test II CPSC 206

Approximately a Test II CPSC 206 Approximately a Test II CPSC 206 Sometime in history based on Kelly and Pohl Last name, First Name Last 5 digits of ID Write your section number(s): All parts of this exam are required unless plainly and

More information

a f b e c d Figure 1 Figure 2 Figure 3

a f b e c d Figure 1 Figure 2 Figure 3 CS2604 Fall 2001 PROGRAMMING ASSIGNMENT #4: Maze Generator Due Wednesday, December 5 @ 11:00 PM for 125 points Early bonus date: Tuesday, December 4 @ 11:00 PM for 13 point bonus Late date: Thursday, December

More information

Programming for Engineers Arrays

Programming for Engineers Arrays Programming for Engineers Arrays ICEN 200 Spring 2018 Prof. Dola Saha 1 Array Ø Arrays are data structures consisting of related data items of the same type. Ø A group of contiguous memory locations that

More information

Understanding Pointers

Understanding Pointers Division of Mathematics and Computer Science Maryville College Pointers and Addresses Memory is organized into a big array. Every data item occupies one or more cells. A pointer stores an address. A pointer

More information

Arrays and Pointers (part 2) Be extra careful with pointers!

Arrays and Pointers (part 2) Be extra careful with pointers! Arrays and Pointers (part 2) EECS 2031 22 October 2017 1 Be extra careful with pointers! Common errors: l Overruns and underruns Occurs when you reference a memory beyond what you allocated. l Uninitialized

More information

Midterm Exam Nov 8th, COMS W3157 Advanced Programming Columbia University Fall Instructor: Jae Woo Lee.

Midterm Exam Nov 8th, COMS W3157 Advanced Programming Columbia University Fall Instructor: Jae Woo Lee. Midterm Exam Nov 8th, 2012 COMS W3157 Advanced Programming Columbia University Fall 2012 Instructor: Jae Woo Lee About this exam: - There are 4 problems totaling 100 points: problem 1: 30 points problem

More information

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

Programming & Data Structure

Programming & Data Structure File Handling Programming & Data Structure CS 11002 Partha Bhowmick http://cse.iitkgp.ac.in/ pb CSE Department IIT Kharagpur Spring 2012-2013 File File Handling File R&W argc & argv (1) A file is a named

More information

Arrays and Pointers (part 2) Be extra careful with pointers!

Arrays and Pointers (part 2) Be extra careful with pointers! Arrays and Pointers (part 2) CSE 2031 Fall 2011 23 October 2011 1 Be extra careful with pointers! Common errors: Overruns and underruns Occurs when you reference a memory beyond what you allocated. Uninitialized

More information

Project 2: Shell with History1

Project 2: Shell with History1 Project 2: Shell with History1 See course webpage for due date. Submit deliverables to CourSys: https://courses.cs.sfu.ca/ Late penalty is 10% per calendar day (each 0 to 24 hour period past due). Maximum

More information

Final Exam 1 /12 2 /12 3 /10 4 /7 5 /4 6 /10 7 /8 8 /9 9 /8 10 /11 11 /8 12 /10 13 /9 14 /13 15 /10 16 /10 17 /12. Faculty of Computer Science

Final Exam 1 /12 2 /12 3 /10 4 /7 5 /4 6 /10 7 /8 8 /9 9 /8 10 /11 11 /8 12 /10 13 /9 14 /13 15 /10 16 /10 17 /12. Faculty of Computer Science Faculty of Computer Science Page 1 of 21 Final Exam Term: Fall 2018 (Sep4-Dec4) Student ID Information Last name: First name: Student ID #: CS.Dal.Ca userid: Course ID: CSCI 2132 Course Title: Instructor:

More information

CS 302: INTRODUCTION TO PROGRAMMING IN JAVA. Chapter 5: Methods. Lecture 10

CS 302: INTRODUCTION TO PROGRAMMING IN JAVA. Chapter 5: Methods. Lecture 10 CS 302: INTRODUCTION TO PROGRAMMING IN JAVA Chapter 5: Methods Lecture 10 1 PROBLEM What if I was using a lot of different arrays and often wanted to print out their contents? I would have to have that

More information

School of Computer Science Introduction to Algorithms and Programming Winter Midterm Examination # 1 Wednesday, February 11, 2015

School of Computer Science Introduction to Algorithms and Programming Winter Midterm Examination # 1 Wednesday, February 11, 2015 Page 1 of 8 School of Computer Science 60-141-01 Introduction to Algorithms and Programming Winter 2015 Midterm Examination # 1 Wednesday, February 11, 2015 Marking Exemplar Duration of examination: 75

More information

Lecture 12 CSE July Today we ll cover the things that you still don t know that you need to know in order to do the assignment.

Lecture 12 CSE July Today we ll cover the things that you still don t know that you need to know in order to do the assignment. Lecture 12 CSE 110 20 July 1992 Today we ll cover the things that you still don t know that you need to know in order to do the assignment. 1 The NULL Pointer For each pointer type, there is one special

More information

Section 1: C Programming Lab

Section 1: C Programming Lab Course Code : MCSL-017 Course Title : C and Assembly Language Programming (Lab Course) Assignment Number : MCA(1)/015/Assignment/17-18 Maximum Marks : 100 Weightage : 25% Last Dates for Submission : 15th

More information

California Common Core State Standards Comparison - FIRST GRADE

California Common Core State Standards Comparison - FIRST GRADE 1. Make sense of problems and persevere in solving them. 2. Reason abstractly and quantitatively. 3. Construct viable arguments and critique the reasoning of others 4. Model with mathematics. Standards

More information

The detail of sea.c [1] #include <stdio.h> The preprocessor inserts the header file stdio.h at the point.

The detail of sea.c [1] #include <stdio.h> The preprocessor inserts the header file stdio.h at the point. Chapter 1. An Overview 1.1 Programming and Preparation Operating systems : A collection of special programs Management of machine resources Text editor and C compiler C codes in text file. Source code

More information