Question 2. [5 points] Given the following symbolic constant definition

Similar documents
Question 2. [2 points] True False By default, structures are passed-by-reference.

Exam 3 Chapters 7 & 9

a. a * c - 10 = b. a % b + (a * d) + 7 =

Introduction to FORTRAN

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

Chapter 3. Computer Science & Engineering 155E Computer Science I: Systems Engineering Focus. Existing Information.

C++ Programming: From Problem Analysis to Program Design, Fifth Edition. Chapter 6: User-Defined Functions I

UNIVERSITY OF LIMERICK OLLSCOIL LUIMNIGH COLLEGE OF INFORMATICS & ELECTRONICS DEPARTMENT OF ELECTRONIC & COMPUTER ENGINEERING

CC112 Structured Programming

Chapter 1: Symmetry and Surface Area

Function I/O. Function Input and Output. Input through actual parameters. Output through return value. Input/Output through side effects

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

Computer Science & Engineering 150A Problem Solving Using Computers

Question 2. [2 points] Which of the following is a correct statement to obtain user input? (Assume that fleems is an int variable.

Computer Science & Engineering 150A Problem Solving Using Computers. Chapter 3. Existing Information. Notes. Notes. Notes. Lecture 03 - Functions

CS 101, Spring 2014 April 1st Exam 2 Question 1. [3 points] What output is printed by the following code?

Function I/O. Last Updated 10/30/18

Introduction to Computers II Lecture 4. Dr Ali Ziya Alkar Dr Mehmet Demirer

Volume of Cylinders. Volume of Cones. Example Find the volume of the cylinder. Round to the nearest tenth.

Structured Programming. Dr. Mohamed Khedr Lecture 4

This is CS50. Harvard University Fall Quiz 0 Answer Key

Give one example where you might wish to use a three dimensional array

Chapter 5 Lab Methods

Outline. Functions. Functions. Predefined Functions. Example. Example. Predefined functions User-defined functions Actual parameters Formal parameters

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

Chapter 5 Lab Methods

LAB 6 FUNCTIONS I School of Computer and Communication Engineering

Functions that Return a Value. Approximate completion time Pre-lab Reading Assignment 20 min. 92

Introduction to Java Applications

Lab Session # 1 Introduction to C Language. ALQUDS University Department of Computer Engineering

SECTION A TRUE / FALSE QUESTIONS (10 MARKS) (INSTRUCTION: Please answer all 10 questions)

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

DEPARTMENT OF COMPUTER ENGINEERING CMPE101: Foundation of Computer Engineering EXPERIMENT 3. Introduction to C Programming: Sequential code structure

For Teacher's Use Only Q No Total Q No Q No

Properties of a Circle Diagram Source:

CS-211 Fall 2017 Test 1 Version A Oct. 2, Name:

Honors Computer Science C++ Mr. Clausen Program 3A, 3B, 3C

Lecture 16. Daily Puzzle. Functions II they re back and they re not happy. If it is raining at midnight - will we have sunny weather in 72 hours?

S8.6 Volume. Section 1. Surface area of cuboids: Q1. Work out the surface area of each cuboid shown below:

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

Variables in C. CMSC 104, Spring 2014 Christopher S. Marron. (thanks to John Park for slides) Tuesday, February 18, 14

CS 101, Spring 2016 March 22nd Exam 2

Surface Area and Volume

Today. o main function. o cout object. o Allocate space for data to be used in the program. o The data can be changed

Variables in C. Variables in C. What Are Variables in C? CMSC 104, Fall 2012 John Y. Park

WARM UP LESSONS BARE BASICS

BSM540 Basics of C Language

NWEN 241 Systems Programming Exercises (Set 1)

Aptitude Volume and Surface Area. Theory

Week 2: Console I/O and Operators Arithmetic Operators. Integer Division. Arithmetic Operators. Gaddis: Chapter 3 (2.14,3.1-6,3.9-10,5.

CS 115 Exam 3, Spring 2010

Spring 2013 COMP Midterm Exam Solutions March 07, 2013

Multiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible)

Functions. Lecture 6 COP 3014 Spring February 11, 2018

Computer Programming, I. Laboratory Manual. Experiment #2. Elementary Programming

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

Question 1. [5 points] Circle and briefly explain the error(s) in the following code:

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

Unit 4 End-of-Unit Assessment Study Guide

Multiple Choice Questions ( 1 mark)

Name. Classes and Objects 1. We re going to develop a class to help out Café Below is the definition for a class called

Chapter 5 C Functions

QUIZ Lesson 4. Exercise 4: Write an if statement that assigns the value of x to the variable y if x is in between 1 and 20, otherwise y is unchanged.

LAB: INTRODUCTION TO FUNCTIONS IN C++

cd h: mkdir -p CS101 cd CS101 curl -O unzip zipfile cd CS101_Exam4

Math-2 Lesson 6-3: Area of: Triangles, rectangles, circles and Surface Area of Pyramids

Arrays in C. Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. Indian Institute of Technology Kharagpur. Basic Concept

Measurement 1 PYTHAGOREAN THEOREM. The area of the square on the hypotenuse of a right triangle is equal to the sum of the areas of

Constants Lesson Outline

C++ Programming: From Problem Analysis to Program Design, Third Edition

COP 3223 Introduction to Programming with C - Study Union - Fall 2017

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

Decimals. Chapter Five

Expressions and Variables

CSCE 2004 Midterm Exam Spring 2017

CS 2150 Exam 1, Spring 2018 Page 1 of 6 UVa userid:

Center of a sphere. Radius of a sphere. Chord of a sphere. Diameter of a sphere

4. C++ functions. 1. Library Function 2. User-defined Function

You will need the following items: scissors, plate, 5 different colored pencils, protractor, paper to answer questions

Chapter 5 Lab Methods

Multiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible)

Question 1. [5 points] Consider the following partially-complete program, which begins on the left and continues on the right: HERE

Lab 9: Creating a Reusable Class

LAB 6 FUNCTION PART 1 School of Computer and Communication Engineering Universiti Malaysia Perlis

COP 3223 Introduction to Programming with C - Study Union - Fall 2017

Learning Coding and Math with RoboBlockly Teaching Resource for Grade 7 Math

Determine the surface area of the following square-based pyramid. Determine the volume of the following triangular prism. ) + 9.

Object-Based Programming. Programming with Objects

FORM 2 (Please put your name and form # on the scantron!!!!)

CS Spring 05 - MidTerm

Full file at

Lecture 12 Modular Programming with Functions

Functions. A function is a subprogram that performs a specific task. Functions you know: cout << Hi ; cin >> number;

Practice Midterm 1. Problem Points Score TOTAL 50

- HALF YEARLY EXAM ANSWER KEY DEC-2016 COMPUTER SCIENCE ENGLISH MEDIUM

Lesson 10T ~ Three-Dimensional Figures

C Tutorial: Part 1. Dr. Charalampos C. Tsimenidis. Newcastle University School of Electrical and Electronic Engineering.

FORM 2 (Please put your name and form # on the scantron!!!!) CS 161 Exam II:

C++, How to Program. Spring 2016 CISC1600 Yanjun Li 1

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

Transcription:

CS 101, Spring 2012 Mar 20th Exam 2 Name: Question 1. [5 points] Determine which of the following function calls are valid for a function with the prototype: void drawrect(int width, int height); Assume variables a, b, length, width, height, and x all have type int. I drawrect(int a, int b); II drawrect(length, length*2); III void drawrect(width, height); IV drawrect(10, sqrt(x)); a. I only b. II only c. III only d. II and IV e. I, II, and IV Question 2. [5 points] Given the following symbolic constant definition #define SIZE 10 what is the proper way to declare an array named cost that can hold at most 11 double values: a. int cost[size]; b. double cost[size+1]; c. void cost[]; d. double cost(size); e. None of the above.

Question 3. [5 points] What output is printed by the following program (which begins on the left and continues on the right)? #include <stdio.h> int halfvalue(int num); int main(void) { int result = 0; int x = 5; halfvalue(x); printf("%i",result); return 0; int halfvalue(int num) { int result; result = num/2; return result; a. 0 b. 2 c. 2.5 d. 5 e. Does not compile. Question 4. [5 points] What must be present in a function prototype? a. function name, variable assignments, symbolic constants b. return type, function name, parameter list c. argument list, array access, return type d. int main(), return statement, array initialization e. function call, argument expressions, variable assignment Question 5. [5 points] Identify the error(s) in the following function. For each error, briefly explain how to fix it. void xray(int x, int y) { float x; x = pow(x,y) return x;

Question 6. [15 points] Write definitions for the functions described below. (The definition specifies the body (code) of the function.) Each description specifies the formula you should use to compute the function s result. Each function takes a single parameter (the given value). Hints: the M PI constant is a close approximation of π, and the sqrt function computes the square root of a double value. (a) Given the area a of a circle, compute its radius r. Use the formula r = a/π (b) Given the radius r of a circle, compute its circumference c. Use the formula c = 2πr (c) Given the circumference c of a circle, compute its diameter d. Use the formula d = c/π Question 7. [5 points] Using the function or functions you wrote for Question 6, write statements that prompt the user to enter the area of a circle and then print the diameter of the circle with that area. The output should use two points of precision (two places after the decimal point.)

For Questions 8 15, circle True or False. Question 8. [2 points] True False A function can only return one value. Question 9. [2 points] True False Every function must return a value. Question 10. [2 points] True False If you attempt to enter a value into an array that is out of bounds the array will grow accordingly. Question 11. [2 points] True False To determine the number of elements in an array called X you can use X.size() Question 12. [2 points] True False The elements of a one-dimensional array are variables. Question 13. [2 points] True False The following is valid: char Alphabet[26]; Question 14. [2 points] True False When accessing an array, the first index is always 1. Question 15. [2 points] True False double values. A single one-dimensional array can contain both int and

Questions 16 18 are programming questions.