COMP Assignment 1

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

CC112 Structured Programming

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

Laboratory 2: Programming Basics and Variables. Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information

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

CSCI 3300 Assignment 6

These are reserved words of the C language. For example int, float, if, else, for, while etc.

Computer System and programming in C

The Program Specification:

CSCI 3300 Assignment 6

CSE/EEE 230 Computer Organization and Assembly Language

COMP105 Assignment 2: Higher order functions

COMP26120 Academic Session: Lab Exercise 2: Input/Output; Strings and Program Parameters; Error Handling

Parallel Programming Pre-Assignment. Setting up the Software Environment

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

CSCI 3300 Assignment 7

COMP250: Introduction to Computer Science. Jérôme Waldispühl & Carlos Oliver Gonzalez School of Computer Science McGill University

CpSc 1111 Lab 6 Conditional Statements, Loops, the Math Library, and Random Numbers What s the Point?

CSCI 3300 Assignment 7

ME 172. Sourav Saha. Md. Mahamudul Hossain Kazi Fazle Rabbi Saddam Hossain Joy Kamruzzaman Lecturer,Dept. of ME,BUET

CpSc 1011 Lab 5 Conditional Statements, Loops, ASCII code, and Redirecting Input Characters and Hurricanes

Chapter 2 THE STRUCTURE OF C LANGUAGE

Program Assignment 2

CpSc 1111 Lab 5 Formatting and Flow Control

At the end of this module, the student should be able to:

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

Overview of C, Part 2. CSE 130: Introduction to Programming in C Stony Brook University

Lab 2: Structured Program Development in C

CpSc 1111 Lab 9 2-D Arrays

EECE.2160: ECE Application Programming Spring 2017

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

UNIT - I. Introduction to C Programming. BY A. Vijay Bharath

CSCI 3300 Assignment 5

Practical 2: Ray Tracing

Com S 227 Assignment Submission HOWTO

CS 2604 Minor Project 1 DRAFT Fall 2000

CSCI 3300 Assignment 3

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

EECE.2160: ECE Application Programming Spring 2019

COMP251: Algorithms and Data Structures. Jérôme Waldispühl School of Computer Science McGill University

Introduction to the C++ Programming Language

Should you know scanf and printf?

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

Assignment 4. Overview. Prof. Stewart Weiss. CSci 335 Software Design and Analysis III Assignment 4

Project 2: Genetic Programming for Symbolic Regression

CSCI 3300 Assignment 3

Use a calculator and c = 2 π r to calculate the circumference of a circle with a radius of 1.0.

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

CPE 101, reusing/mod slides from a UW course (used by permission) Lecture 5: Input and Output (I/O)

Structured Programming. Dr. Mohamed Khedr Lecture 4

Euclid s algorithm, 133

BASIC ELEMENTS OF A COMPUTER PROGRAM

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

CS102: Standard I/O. %<flag(s)><width><precision><size>conversion-code

ME 172. Lecture 2. Data Types and Modifier 3/7/2011. variables scanf() printf() Basic data types are. Modifiers. char int float double

Display Input and Output (I/O)

CMPT 102 Introduction to Scientific Computer Programming. Input and Output. Your first program

2. You are required to enter a password of up to 100 characters. The characters must be lower ASCII, printing characters.

Setting up a Turnitin Dropbox

CS 2704 Project 3 Spring 2000

Expressions. Arithmetic expressions. Logical expressions. Assignment expression. n Variables and constants linked with operators

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program

How to.. submit assignments via Blackboard. EAS How to guide 1

CS 101, Spring 2016 March 22nd Exam 2

Introduction to C CMSC 104 Spring 2014, Section 02, Lecture 6 Jason Tang

EECE.2160: ECE Application Programming Fall 2017 Exam 3 December 16, 2017

CS 344/444 Spring 2008 Project 2 A simple P2P file sharing system April 3, 2008 V0.2

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

Overview. - General Data Types - Categories of Words. - Define Before Use. - The Three S s. - End of Statement - My First Program

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

Fundamentals of Programming Session 8

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

Programming for Engineers Introduction to C

Jim Lambers ENERGY 211 / CME 211 Autumn Quarter Programming Project 2

Objectives. In this chapter, you will:

CSCI 3300 Assignment 4

2005 Stanford Local Programming Contest

Introduction to the coursework for CI228

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

COSC2031 Software Tools Introduction to C

CSCI 4000 Assignment 1

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

[Page 177 (continued)] a. if ( age >= 65 ); cout << "Age is greater than or equal to 65" << endl; else cout << "Age is less than 65 << endl";

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

Programming Assignment 2 ( 100 Points )

Web-CAT Guidelines. 1. Logging into Web-CAT

Lecture 2. Examples of Software. Programming and Data Structure. Programming Languages. Operating Systems. Sudeshna Sarkar

2 nd Week Lecture Notes

Sir Syed University of Engineering and Technology. Computer Programming & Problem Solving ( CPPS )

Input/Output Week 5:Lesson 16.1

Dept. of CSE, IIT KGP

MA 511: Computer Programming Lecture 2: Partha Sarathi Mandal

CS 2604 Minor Project 1 Summer 2000

Chapter 2 C++ Fundamentals

CpSc 1011 Lab 4 Formatting and Flow Control Windchill Temps

Hardware Description and Verification Lava Exam

COMP 202 Java in one week

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #16 Loops: Matrix Using Nested for Loop

Fundamentals of Programming. Lecture 6: Structured Development (part one)

9/10/2016. Time for Some Detailed Examples. ECE 120: Introduction to Computing. Let s See How This Loop Works. One Statement/Step at a Time

Transcription:

COMP281 2019 Assignment 1 In the following, you will find the problems that constitute Assignment 1. They will be also available on the online judging (OJ) system available at https://student.csc.liv.ac.uk/judgeonline You need to write a C program (not C++ or C#) that solves each problem it must read the input, as specified in the problem description then print the solution to the given problem for that input. o Note that code is correct only if it correctly implements a solution to the problem stated in the assignment, not "if online judge accepts it". o That is, even if OJ accepts your code, it could be wrong. Read the problems carefully. is read from the standard input, in the same way that you read input from the keyboard as shown in lectures (e.g., using scanf). is also printed to the standard output, as you have seen (e.g., using printf). When you are satisfied that your C programs work correctly, you must submit them through the departmental submission system. o Even if the program is not correct, still submit whatever you have! You can still earn points if certain parts of the code are done right. You must also include a brief report describing your solutions to the problems. This should be maximum two sides of A4 paper and should give a description of how each of your solutions works. This should include describing the algorithm used to reach the solution, describing your use of any C language features (that were not discussed in lectures) and identifying any resources that you have used to help you solve the problems. This assignment is worth 50% of the total mark (100) for COMP281. o All problems are weighted equally. o For each problem, you can earn a total of 20 points 10 points for Functionality and Correctness awarded for programs that correctly solve the problem for all test cases. 8 points for Programming style, use of comments, indentation and identifiers awarded depending on the style, comments and efficiency of the solution 2 points for the quality and depth of the accompanying report o The final grade results from normalising the earned points to a scale of 100. o See separate comp281-detailed-marking-guidelines.pdf for more details.

Submission Instructions Create a folder, and name it using your Student ID and User ID, e.g. 201234567_sgxyz6 In the folder, there should be 6 files: o 1 report file, in PDF format. Name it with your Student ID and User ID, e.g. 201234567_sgxyz6.pdf o 5 source code files. Name each using the Problem Number, e.g. 1006.c In your source code, include your Student Info and Problem Info, e.g.: /* * Student ID: 201234567 * Student Name: Bruce Lee * Email: bruce.lee@student.liverpool.ac.uk * * User: sgxyz6 * * Problem ID: 1006 * RunID: 22456 * Result: Accepted */ The OJ provides a RunID, which is different from the Problem ID. The Result is one of the following: Accepted, Wrong Answer, Presentation Error, Time Limit Exceeded, Memory Limit Exceeded, Limit Exceeded, Runtime Error, Compile Error. Compress the folder into a single zip file, and name it as, e.g. 201234567_sgxyz6.zip o Use the standard (pkzip) zip file format: https://en.wikipedia.org/wiki/zip_%28file_format%29 which is supported by winzip, winrar, etc. on Windows/Mac OS X, and 'zip' on Linux o Test your zip file before submitting. Submit this zip file using the departmental submission system at http://www.csc.liv.ac.uk/cgi-bin/submit.pl Only the file submitted through this link will be marked. The deadline for this assignment submission is 22-Feb-2019 17:00 Penalties for late submission apply in accordance with departmental policy as set out in the student handbook, which can be found at: http://intranet.csc.liv.ac.uk/student/ug-handbook.pdf

1. Problem 1013 Title: Record marks You are in charge of recording marks for a group of students. a list of marks. ends with 0 (0 itself is not someone's mark). the number of students who scored 1) greater than or equal to 85; 2) between 60 and 84; 3) strictly less than 60. Make sure you use good coding standards: i.e., create separate functions for processing the input and writing the output, and be consistent in the way you name variables (also see the COMP 281 Detailed Marking Guidelines ). Sample 88 71 68 70 59 81 91 42 66 77 83 0 Sample >=85:2 60-84:7 <60:2 Remember that there are different ways of obtaining input. For this assignment "scanf" might be convenient, but make sure to use the correct syntax (it requires a 'pointer' as a second argument.)

2. Problem 1014 Title: Area and circumference of circles In this exercise you have to compute the area and circumference of a series of circles and output their sum. Specifically, the program will take two radius of two circles as input (r1 <= r2, both integers) and will output the sum of the areas and the circumferences of all circles starting with r1 and increasing at each step the radius by '1' until radius r2 has been reached. As an example, suppose 'r2-r1 = 2' then the program has to compute the sum of the areas and circumferences of three circles with radii r1, r1+1,r2. Remember that the area of a circle equals Pi*r^2 and the circumference equals 2Pi*r. Set Pi to 3.14 Two integers r1 and r2 with r1<=r2. Two floats, sumofareas and sumofcircumferences. The result should be in 3 digits precision. Sample 3 4 Sample 78.500 43.960

3. Problem 1015 Title: ASCII code Convert integers (ASCII codes) to characters. A list of positive integers separated by whitespaces (spaces, newlines, TABs). The input ends with EOF. A list of characters. (Do not add end-of-line at the end of the output.) Sample 72 101 108 108 111 44 32 119 111 114 108 100 33 Sample Hello, world! H's ASCII code is 72. Blank space's ASCII code is 32.

4. Problem 1025 Title: Largest common factor and smallest common multiple two positive integers. Compute their largest common factor and smallest common multiple. Sample 2 3 Sample 1 6

5. Problem 1030 Title: Precise division 8/13=0.615384615384615384615384... For 8/13, the 5-th digit after the decimal point is 8. Given three positive integers a, b, and n (all at most 60000), you are asked to compute a/b and print out the n- th digit after the decimal point. a b n The n-th digit after the decimal point of a/b. Sample 8 13 5 Sample 8