York University Faculty Science and Engineering Fall 2008

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

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

CpSc 1010, Fall 2014 Lab 10: Command-Line Parameters (Week of 10/27/2014)

CSE 351. Introduction & Course Tools

CSE 374 Midterm Exam Sample Solution 2/6/12

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

CSCI 2132 Final Exam Solutions

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

ECE264 Fall 2013 Exam 1, September 24, 2013

Mastering Modern Linux by Paul S. Wang Appendix: Pattern Processing with awk

Pointers and scanf() Steven R. Bagley

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

CS-211 Fall 2017 Test 1 Version Practice For Test on Oct. 2, Name:

CSC111 Computer Science II

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

Approximately a Test II CPSC 206

1. The keyword main in C language is used for

Chapter 11 Introduction to Programming in C

EECS2031 Software Tools

CSCI 111 Midterm 1, version A Exam Fall Solutions 09.00am 09.50am, Tuesday, October 13, 2015

Bristol Institute of Technology

ESC101N: Fundamentals of Computing End-sem st semester

CS 361 Computer Systems Fall 2017 Homework Assignment 1 Linking - From Source Code to Executable Binary

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

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

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

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

Chapter 11 Introduction to Programming in C

Quiz1 Fall 2007 October 2 nd, UNIVERSITY OF WINDSOR Fall 2007 QUIZ # 1 Solution. Examiner:Ritu Chaturvedi Dated :October 2nd, 2007.

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

Lab 2: Performance Measurement Date: 12 June 2009 Number of Problems: 4

CSE 115 Programming Language I Final Examination Fall 2015

CSE 303 Lecture 8. Intro to C programming

For questions 4 through 7, select the value assigned to the relevant variable, given the declarations: 3) ) This is not allowed

In this introduction to UNIX, only the dumb terminal (also known as the command line ) interface is discussed.

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

1. The Mac Environment in SIE 1222

CS 326 Operating Systems C Programming. Greg Benson Department of Computer Science University of San Francisco

CS 3113 Introduction to Operating Systems Midterm October 11, 2018

CS 3113 Introduction to Operating Systems Midterm October 11, 2018

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

Introduction to Computing V - Linux and High-Performance Computing

to calculate Fib(N) very quickly 1 Task 1: High-school algebra helps to design your program

CS240: Programming in C

UNIVERSITY OF WINDSOR Fall 2006 QUIZ # 1. Examiner:Ritu Chaturvedi Dated : Oct 3rd, Student Name: Student Number:

ECE264 Fall 2013 Exam 3, November 20, 2013

COURSE: COMPUTER FUNDAMENTALS AND PC SOFTWARE (MCA -01)

COMP s1 Lecture 1

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

CpSc 1111 Lab 9 2-D Arrays

Oregon State University School of Electrical Engineering and Computer Science. CS 261 Recitation 1. Spring 2011

LSN 3 C Concepts for OS Programming

Program Organization and Comments

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

Exercise 1: Basic Tools

Final CSE 131B Spring 2004

Flex and lexical analysis. October 25, 2016

Approximately a Final Exam CPSC 206

1. The Mac Environment in Sierra Hall 1242

High Performance Computing MPI and C-Language Seminars 2009

2 Input and Output The input of your program is any file with text. The output of your program will be a description of the strings that the program r

CS 220: Introduction to Parallel Computing. Beginning C. Lecture 2

Chapter 11 Introduction to Programming in C

Chapter 11 Introduction to Programming in C

27-Sep CSCI 2132 Software Development Lecture 10: Formatted Input and Output. Faculty of Computer Science, Dalhousie University. Lecture 10 p.

Programming and Data Structure Laboratory (CS13002)

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

ECE 2036 Lab 1: Introduction to Software Objects

C Overview Fall 2015 Jinkyu Jeong

Scheme G. Sample Test Paper-I. Course Name : Computer Engineering Group Course Code : CO/CD/CM/CW/IF Semester : Second Subject Tile : Programming in C

CMPT 300. Operating Systems. Brief Intro to UNIX and C

University of Toronto

Chapter-8 DATA TYPES. Introduction. Variable:

CSE 374 Midterm Exam 2/6/17 Sample Solution. Question 1. (12 points, 4 each) Suppose we have the following files and directories:

CS 455 Midterm Exam 1 Fall 2017 [Bono] Thursday, Sep. 28, 2017

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

Lecture 03 Bits, Bytes and Data Types

ECE 15 Fall 15 Final Solutions

CSE2301. Arrays and Pointers. These slides are based on slides by Prof. Wolfgang Stuerzlinger at York University. Arrays

CSE 333 Midterm Exam 7/29/13

CSE2301. Arrays. Arrays. Arrays and Pointers

Programming in C. Pointers and Arrays

CSE 1320 INTERMEDIATE PROGRAMMING - OVERVIEW AND DATA TYPES

PRINCIPLES OF OPERATING SYSTEMS

Introduction to Supercomputing

C0MP1911 Final Exam 1337 Computing 1

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

Binary Representation. Decimal Representation. Hexadecimal Representation. Binary to Hexadecimal

Decimal Representation

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

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

CSC UNIX System, Spring 2015

Overview (1A) Young Won Lim 9/14/17

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

Lecture 3. More About C

Physics 234: Computational Physics

Flex and lexical analysis

CSE 220: Systems Programming

Multiple Choice (Questions 1 14) 28 Points Select all correct answers (multiple correct answers are possible)

CSE 303 Midterm Exam

Transcription:

York University Faculty Science and Engineering Fall 2008 CSE2031 Final Software Tools Friday, Feb..26 th, 2008 Last Name 08:30 10:30am First name ID Instructions to students: Answer all questions. Marks are shown in front of each question number. Be neat and clean while drawing your logic, block, or state diagrams. This examination consists of FIVE questions Problem Points 1 /4 2 /8 3 /4 4 /4 5 /11 Lab test 1 /13 Lab test 2 /16 Total /60

Question 1 (4 points) What is the value of the following expression? Give two digits after the decimal point for real numbers. int a = 3; float b = 1.2; double c = 0.4; float x=1.5; b = 25 % a b; Answer: b = b = a = 3.2 / c - 2.5; Answer: a = b = c = (int) 2.8 / 0.5 + 12; Answer: c = x= 1/1+x/1+x*x; Answer: x=

Question 2 (8 points) Write what each command does in Linux ls cd abc mkdir new gcc o code code.c diff file1 file2 od file1 Assume that myprogram is an executable file that uses main(int argc, char** argv). For the command myprogram input1.txt input2.txt output.txt what would be the values of argc and argv[2] respectively: a. 3 and input1.txt b. 3 and input2.txt c. 4 and input1.txt d. d. 4 and input2.txt

Question 3 (4 points) These are four valid C declarations (all related to pointers). Each declaration is followed by a description of what the expression means (in parentheses). Which one of the descriptions is not accurate? a. FILE *fp; (fp is a pointer to a file named FILE.) b. char *word; (word is a string, or an array of characters.) c. char *words[ ]; (words is an array of strings.) d. char **words; (words is an array of strings.) The following program reads the students score and calculates the number of students who scored more than 90%. The program also prints a message stating if the student is an A+ or not. There are some syntax errors, correct it. if(score >=0.9) printf( An A+ students \n ); Aplus = Aplus+1; else printf ( Not an A+ student);

Question 4 (4 points) Consider the following two input files file1 This is line one Line two Shorter However, it could be Long essay file2 C is a very powerful Programming language Much faster than awk though But it may be a Little tricky And the awk program file file3 {if (NR >2) print NR, $0} What is the output of the following? awk f file3 file2 file1

Question 5 ( 11 points) Given the variable declarations below: char c, *cp; int n=2, a[100], *ip; Explain whether the following expressions are legal or illegal. For those that are legal, what are their effect? (or what do they do?) cp = c; Legal Illegal cp = &c; Legal Illegal *cp = &c; Legal Illegal cp = &a; Legal Illegal &cp = c; Legal Illegal &cp = &c; Legal Illegal ip = &a; Legal Illegal ip = a; Legal Illegal ip = &a[0]; Legal Illegal (ip = a) + n; Legal Illegal *((ip=a)+n) = 5; Legal Illegal

York University Faculty Science and Engineering CSE2031 Final Exam (Lab test part) Fall 2008 LABTEST PART In this part, you have to write two programs. Choose one program from programs 1 and 2, and another from programs 3,4 Program 1: Write a program that reads an integer and writes the digit values in English The input is one integer; ignore any spaces, or any input after the integer For example if the input is 1256 The output is: one two five six Just one space between 2 words. No spaces before the first word. No spaces or newlines after the last word. Submit as f1

Program 2: The numbers from 1 to 100 are placed in a square array of size 10x10 as shown. Write a program that reads 2 numbers between 1 to a 100 and calculate the area of the rectangle whose diagonal vertices are these 2 numbers. For example if the two input numbers are 13 56 the output should be 20 1 2 3 4 5 6 7 8 9 10 11 12 13 20 21.... 31.. 51 52 53 54 55 56 91 92 92.... 100 If the input is 14 54 the output should be 5 1 2 3 4 5 6 7 8 9 10 11 12 13 14 20 21.... 31.. 51 52 53 54 55 56 91 92 92.... 100 Keep in mind the numbers could be entered in any order, for example 13 56 are the same as 56 13 The input 2 numbers at the same line separated by one or more space. The output is one integer followed by a new line. Submit as f2

Program 3: Write a program that reads some integers from the standard input and expand them For examples Input Output 1 2 3 4 5 1 2 3 4 5 4-9 4 5 6 7 8 9 1 2-6 8 9 1 2 3 4 5 6 8 9 1-3 6 8-12 1 2 3 6 8 9 10 11 12 8-8 8 8-7 The input is a sequence of integers may be separated by dashes. The integers are separated by one or more space. If we have a dash, then there is no separation between the dash and the two integers it is joining. The output is a sequence of integers separated by a single space ended by a new line (no space before the new line). Submit as f3

Program 4: Write a program that adds two integer numbers of arbitrary length. The two numbers have a maximum length of 50 digits. the input is on the form of one number per line, the output is one number followed by a new line. The two numbers to be added may have leading 0 s. The output should not have a zero in the most significant digit position For example Input 12345678765891245678190 65413201434514345543411 The output is 77758880200405591221601 Submit as f4