Solutions to Assessment: Basic Programming Constructs
|
|
- Marjorie Mills
- 7 years ago
- Views:
Transcription
1 Solutions to Assessment: Basic Programming Constructs Question 1: Specify the minimum number of comparisons required to find the largest number among a set of 3 integers X, Y and Z. We already know how to find the largest number between X, Y and Z using 2 comparisons. Using 1 comparison, we can compare only two numbers; so there is no way of telling the largest among X, Y, Z using just 1 comparison. Therefore, the answer is 2 Ans: 2 Question 2: Specify the minimum number of comparisons required to find the largest number among a set of 4 integers W, X, Y and Z. We need N-1 comparisons in general to find the minimum of N numbers. Ans: 3 Question 3: What is the value of variable a at the end of the following program segment? 1. int a,b,c,d,e; 2. a = 6; 3. b = 3; 4. c = -2; 5. d = 2;e = 4; 6. a = a * b; 7. d = d * 2; 8. a = a + c * d / e; 9. a = a - 5; Value of variable a after execution of line 6 is 18 Value of variable d after execution of line 7 is 4 Line 8 can be re-written as a = (a + ((c*d)/e)), because operators * and / have an equal precedence, which is higher than + Value of variable a after execution of line 8 is 16 Value of variable a after execution of line 9 is 11 Ans: 11 Question 4: What is the value of variable a at the end of the following program segment?
2 b = 10; a = b++; The expression b++ increments the value of the variable b to 11, but the expression b++ evaluates to the value 10. This value is assigned to the variable a. Ans: 10 Note: ++ in the expression b++ is called post-increment operator. Operator ++ can also be written before a variable s name (Eg: ++b). In that case, it s called pre-increment operator and the expression ++b evaluates to 11 Question 5: Which among the following operators has the highest precedence? a.) * b) == c) & d) + The order of precedence for the operators in descending order is as follows: *, +, ==,& Ans: a Question 6: What is the output of the following code segment? int x=10; int y=5; printf("%d",(y,x)); In the expression (y, x) comma acts as an operator. The expression (y, x) evaluates to the second value, i.e. x. Thus the value of variable x is printed. Please see for more examples Ans: 10 Question 7: What is the output of the following code segment? int x=1000; int y=5000; printf("%d",y,x); In this question, comma acts only as separator. printf() statement prints the value of the variable y and ignores the variable x
3 Ans: 5000 Question 8: What is the output of the following code segment? int a=10,b=200; int c; c=a,b; printf("%d",c); c = a, b; is equivalent to (c = a), b; so the variable c is assigned the value of variable a. Therefore the answer is 10. Please see for more examples Ans: 10 Question 9: Consider the following code snippet. What is the output if x is 10? switch(x) default: printf( x ); case 10: printf( y ); case 20: printf( z ); In switch statement, code under a matching label is first executed, and the execution continues till the end of switch. When x = 10; case 10: block is executed and then case 20: Ans: yz Question 10: What is the output of the following code snippet? 1. int x=10; 2. if (x==5) 3. printf("5"); 4. if (x%5==0) 5. printf("10"); 6. else 7. printf("bye");
4 In line 2, x == 5 evaluates to 0 (or False), line 3 doesn t get executed. In line 4, x % 5 == 0 evaluates to 1(or True), statement in line 5 is executed. else in line 6 is not executed obviously because if statement was already true. Ans: 10 Question 11: What is the output of the following code snippet? 1. int x=5; 2. if ( x < 10 ) 3. printf( "<10" ); 4. else if ( x % 2 == 0 ) 5. printf( "even" ); 6. else if ( x >= 5) 7. printf(">=5" ); 8. else 9. printf( "odd and <=5"); In if else if else construct, only the first true statement will be executed. x < 10 in Line 2 evaluates to True, Line 3 will be executed. Ans: <10 Question 12: Is the program segment below valid? for(;;); The statement above is a valid C statement Ans: Yes Question 13: What is of the following is the output of the following code segment? int i; for(i=1;i++<=5;printf( %d,i)); for(variable initialization; condition; variable update) Code to execute while the condition is true For the first iteration, condition is executed and if it evaluates to True, the body of for loop is executed. For the subsequent iterations, statement(s) in variable update is/are executed, followed by statement(s)
5 in condition. If condition evaluates to True, body of the for loop is executed. Also note that, if i = 5, the statement i++ evaluates to 5; and hence i++ <= 5 evaluates to True Ans: Question 14: What is the output of the following code segment? int i=1; while(i++<5); printf("%d",i); The while loop starts with the check (1 < 5) but it gets post-incremented to 2. This loop continues till i = 5. When you check (i++ < 5), it evaluates (5 <5) which is FALSE and the loop exits. However, because of i++, i gets incremented to 6. The result printed would be 6. Ans: 6 Question 15: What is the output of the following code segment? 1. int i=1; 2. do 3. while(i++<=5); 4. while(i++<=4); 5. while(i++<=3); 6. printf( %d,i); Just like in Q15, the while loop in Line 3, would leave i with the value 7. The check in line 4, checks (7<=4) but also increments it to 8. Finally, the check in line 9 fails but the value of i gets incremented to 9. Thus 9 is the final answer. Ans: 9 Solutions to Programming Assignments Question 1: Write a program that reads numbers which are in the range 0 to 100, till it encounters -1. Print the sum of all the integers that you have read before you encountered -1
6 INPUT: A sequence of integers separated by whitespace. There may be other integers following -1. OUTPUT: Sum of all integers in the sequence before you encounter -1. Any integer that is input after -1 in the sequence should be ignored. CONSTRAINTS: Atmost 10 integers will be given in the input. One of them is guaranteed to be a -1. s will be in the range 0 to 100 (both included). #include<stdio.h> int main() int sum=0; int number=0; do sum=sum+number; //update partial sum scanf("%d",&number); //read a number from the input while(number!=-1); //check whether recently added number is -1 or not printf("%d",sum); //print the final sum return 0; Public test cases: Private test cases:
7 Question 2: Solution described in the video. Given three points (x1, y1), (x2, y2) and (x3, y3), write a program to check if all the three points fall on one straight line. INPUT: Six integers x1, y1, x2, y2, x3, y3 separated by whitespace. OUTPUT: Print Yes if all the points fall on straight line, No otherwise. CONSTRAINTS: <= x1, y1, x2, y2, x3, y3 <= 1000 #include<stdio.h> int main() int x1,y1,x2,y2,x3,y3; //Reading all 6 integers from the input using scanf() scanf("%d %d %d %d %d %d", &x1,&y1,&x2,&y2,&x3,&y3); //Checking if the slopes (y2-y1)/(x2-x1) == (y3-y2)/(x3-x2). If they are equal, then all the points lie on the same line. //Instead of performing division in LHS and RHS, we cross multiply (x2-x1) and (x3-x2) to handle the case when either (x2-x1) = 0 or (x3-x2) = 0. if ((y2-y1)*(x3-x2) == (y3-y2)*(x2-x1)) printf("yes"); else printf("no"); return 0; PUBLIC TEST CASES:
8 Yes Yes No Yes PRIVATE TEST CASES: No Yes No Yes No Yes Yes Yes Question 3: The digital root (also called repeated digital sum) of a number is a single digit value obtained by an iterative process of summing digits. Digital sum of is 7, because =25 and 2+5 = 7. Write a program that takes an integer as input and prints its digital root. INPUT: A single integer N OUTPUT: Digital root of the number N. CONSTRAINTS: 1 <= N <= 10^7 PUBLIC TEST CASES:
9 PRIVATE TEST CASES: Check the video posted in the course webpage for a detailed explanation of the following code: #include<stdio.h> int main() int N, sum=0; scanf("%d",&n); while(n>9) sum=0; while(n>0) sum += N%10; N = N/10; N = sum;
10 printf("%d",n); return 0; Question 4: Write a program to print all the factors of a positive integer A. INPUT: A single integer A OUTPUT: Factors of the number A, in ascending order, separated by whitespace. 1 and A are also factors of A. CONSTRAINTS: 2 <= A <= #include<stdio.h> int main() int number; int i=1; scanf("%d",&number); printf("%d",i); for(i=2;i<=number;i++) //iterating over all numbers from 2 to number if(number%i==0) //checking whether 'i' is a factor of number or not printf(" %d",i); //printing a factor with a preceding whitespace return 0; PUBLIC TEST CASES:
11 PRIVATE TEST CASES:
Senem Kumova Metin & Ilker Korkmaz 1
Senem Kumova Metin & Ilker Korkmaz 1 A loop is a block of code that can be performed repeatedly. A loop is controlled by a condition that is checked each time through the loop. C supports two categories
More informationStatements and Control Flow
Contents 1. Introduction 2. Types and Variables 3. Statements and Control Flow 4. Reading Input 5. Classes and Objects 6. Arrays 7. Methods 8. Scope and Lifetime 9. Utility classes 10. Introduction to
More informationSources: On the Web: Slides will be available on:
C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,
More information9 Control Statements. 9.1 Introduction. 9.2 Objectives. 9.3 Statements
9 Control Statements 9.1 Introduction The normal flow of execution in a high level language is sequential, i.e., each statement is executed in the order of its appearance in the program. However, depending
More informationInformatica e Sistemi in Tempo Reale
Informatica e Sistemi in Tempo Reale Introduction to C programming Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 25, 2010 G. Lipari (Scuola Superiore Sant Anna)
More informationPlaying with Numbers
PLAYING WITH NUMBERS 249 Playing with Numbers CHAPTER 16 16.1 Introduction You have studied various types of numbers such as natural numbers, whole numbers, integers and rational numbers. You have also
More informationYear 9 set 1 Mathematics notes, to accompany the 9H book.
Part 1: Year 9 set 1 Mathematics notes, to accompany the 9H book. equations 1. (p.1), 1.6 (p. 44), 4.6 (p.196) sequences 3. (p.115) Pupils use the Elmwood Press Essential Maths book by David Raymer (9H
More informationObject Oriented Software Design
Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 28, 2010 G. Lipari (Scuola Superiore Sant Anna) Introduction
More informationObject Oriented Software Design
Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa September 14, 2011 G. Lipari (Scuola Superiore Sant Anna) Introduction
More informationKeywords are identifiers having predefined meanings in C programming language. The list of keywords used in standard C are : unsigned void
1. Explain C tokens Tokens are basic building blocks of a C program. A token is the smallest element of a C program that is meaningful to the compiler. The C compiler recognizes the following kinds of
More informationIntroduction to Programming (in C++) Loops. Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC
Introduction to Programming (in C++) Loops Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC Example Assume the following specification: Input: read a number N > 0 Output:
More informationExample. Introduction to Programming (in C++) Loops. The while statement. Write the numbers 1 N. Assume the following specification:
Example Introduction to Programming (in C++) Loops Assume the following specification: Input: read a number N > 0 Output: write the sequence 1 2 3 N (one number per line) Jordi Cortadella, Ricard Gavaldà,
More informationPython Lists and Loops
WEEK THREE Python Lists and Loops You ve made it to Week 3, well done! Most programs need to keep track of a list (or collection) of things (e.g. names) at one time or another, and this week we ll show
More informationLecture 2 Notes: Flow of Control
6.096 Introduction to C++ January, 2011 Massachusetts Institute of Technology John Marrero Lecture 2 Notes: Flow of Control 1 Motivation Normally, a program executes statements from first to last. The
More informationThis is a square root. The number under the radical is 9. (An asterisk * means multiply.)
Page of Review of Radical Expressions and Equations Skills involving radicals can be divided into the following groups: Evaluate square roots or higher order roots. Simplify radical expressions. Rationalize
More informationBoolean Expressions, Conditions, Loops, and Enumerations. Precedence Rules (from highest to lowest priority)
Boolean Expressions, Conditions, Loops, and Enumerations Relational Operators == // true if two values are equivalent!= // true if two values are not equivalent < // true if left value is less than the
More informationComputer Science 2nd Year Solved Exercise. Programs 3/4/2013. Aumir Shabbir Pakistan School & College Muscat. Important. Chapter # 3.
2013 Computer Science 2nd Year Solved Exercise Chapter # 3 Programs Chapter # 4 Chapter # 5 Chapter # 6 Chapter # 7 Important Work Sheets Aumir Shabbir Pakistan School & College Muscat 3/4/2013 Chap #
More informationBasics of I/O Streams and File I/O
Basics of This is like a cheat sheet for file I/O in C++. It summarizes the steps you must take to do basic I/O to and from files, with only a tiny bit of explanation. It is not a replacement for reading
More informationIS0020 Program Design and Software Tools Midterm, Feb 24, 2004. Instruction
IS0020 Program Design and Software Tools Midterm, Feb 24, 2004 Name: Instruction There are two parts in this test. The first part contains 50 questions worth 80 points. The second part constitutes 20 points
More informationSAT Math Facts & Formulas Review Quiz
Test your knowledge of SAT math facts, formulas, and vocabulary with the following quiz. Some questions are more challenging, just like a few of the questions that you ll encounter on the SAT; these questions
More informationFactoring Trinomials: The ac Method
6.7 Factoring Trinomials: The ac Method 6.7 OBJECTIVES 1. Use the ac test to determine whether a trinomial is factorable over the integers 2. Use the results of the ac test to factor a trinomial 3. For
More informationKeywords: Dynamic pricing, Hotel room forecasting, Monte Carlo simulation, Price Elasticity, Revenue Management System
Volume 3, Issue 5, May 2013 ISSN: 2277 128X International Journal of Advanced Research in Computer Science and Software Engineering Research Paper Available online at: www.ijarcsse.com Dynamic Pricing
More informationBoolean Algebra Part 1
Boolean Algebra Part 1 Page 1 Boolean Algebra Objectives Understand Basic Boolean Algebra Relate Boolean Algebra to Logic Networks Prove Laws using Truth Tables Understand and Use First Basic Theorems
More informationDigitalCommons@University of Nebraska - Lincoln
University of Nebraska - Lincoln DigitalCommons@University of Nebraska - Lincoln MAT Exam Expository Papers Math in the Middle Institute Partnership 7-1-007 Pythagorean Triples Diane Swartzlander University
More informationEmbedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C
Embedded Systems A Review of ANSI C and Considerations for Embedded C Programming Dr. Jeff Jackson Lecture 2-1 Review of ANSI C Topics Basic features of C C fundamentals Basic data types Expressions Selection
More informationLesson 9: Radicals and Conjugates
Student Outcomes Students understand that the sum of two square roots (or two cube roots) is not equal to the square root (or cube root) of their sum. Students convert expressions to simplest radical form.
More information6. Control Structures
- 35 - Control Structures: 6. Control Structures A program is usually not limited to a linear sequence of instructions. During its process it may bifurcate, repeat code or take decisions. For that purpose,
More informationPseudo code Tutorial and Exercises Teacher s Version
Pseudo code Tutorial and Exercises Teacher s Version Pseudo-code is an informal way to express the design of a computer program or an algorithm in 1.45. The aim is to get the idea quickly and also easy
More informationCubes and Cube Roots
CUBES AND CUBE ROOTS 109 Cubes and Cube Roots CHAPTER 7 7.1 Introduction This is a story about one of India s great mathematical geniuses, S. Ramanujan. Once another famous mathematician Prof. G.H. Hardy
More informationThe Prime Numbers. Definition. A prime number is a positive integer with exactly two positive divisors.
The Prime Numbers Before starting our study of primes, we record the following important lemma. Recall that integers a, b are said to be relatively prime if gcd(a, b) = 1. Lemma (Euclid s Lemma). If gcd(a,
More informationClass One: Degree Sequences
Class One: Degree Sequences For our purposes a graph is a just a bunch of points, called vertices, together with lines or curves, called edges, joining certain pairs of vertices. Three small examples of
More informationPaper 109-25 Merges and Joins Timothy J Harrington, Trilogy Consulting Corporation
Paper 109-25 Merges and Joins Timothy J Harrington, Trilogy Consulting Corporation Abstract This paper discusses methods of joining SAS data sets. The different methods and the reasons for choosing a particular
More informationExample of a Java program
Example of a Java program class SomeNumbers static int square (int x) return x*x; public static void main (String[] args) int n=20; if (args.length > 0) // change default n = Integer.parseInt(args[0]);
More informationChapter 9. Systems of Linear Equations
Chapter 9. Systems of Linear Equations 9.1. Solve Systems of Linear Equations by Graphing KYOTE Standards: CR 21; CA 13 In this section we discuss how to solve systems of two linear equations in two variables
More informationALGEBRA. sequence, term, nth term, consecutive, rule, relationship, generate, predict, continue increase, decrease finite, infinite
ALGEBRA Pupils should be taught to: Generate and describe sequences As outcomes, Year 7 pupils should, for example: Use, read and write, spelling correctly: sequence, term, nth term, consecutive, rule,
More informationName: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.
Name: Class: Date: Exam #1 - Prep True/False Indicate whether the statement is true or false. 1. Programming is the process of writing a computer program in a language that the computer can respond to
More informationThe Little Man Computer
The Little Man Computer The Little Man Computer - an instructional model of von Neuman computer architecture John von Neuman (1903-1957) and Alan Turing (1912-1954) each independently laid foundation for
More informationQUIZ-II QUIZ-II. Chapter 5: Control Structures II (Repetition) Objectives. Objectives (cont d.) 20/11/2015. EEE 117 Computer Programming Fall-2015 1
QUIZ-II Write a program that mimics a calculator. The program should take as input two integers and the operation to be performed. It should then output the numbers, the operator, and the result. (For
More informationFlowchart Techniques
C H A P T E R 1 Flowchart Techniques 1.1 Programming Aids Programmers use different kinds of tools or aids which help them in developing programs faster and better. Such aids are studied in the following
More informationQUADRATIC EQUATIONS EXPECTED BACKGROUND KNOWLEDGE
MODULE - 1 Quadratic Equations 6 QUADRATIC EQUATIONS In this lesson, you will study aout quadratic equations. You will learn to identify quadratic equations from a collection of given equations and write
More informationIn this Chapter you ll learn:
Now go, write it before them in a table, and note it in a book. Isaiah 30:8 To go beyond is as wrong as to fall short. Confucius Begin at the beginning, and go on till you come to the end: then stop. Lewis
More informationFEEG6002 - Applied Programming 5 - Tutorial Session
FEEG6002 - Applied Programming 5 - Tutorial Session Sam Sinayoko 2015-10-30 1 / 38 Outline Objectives Two common bugs General comments on style String formatting Questions? Summary 2 / 38 Objectives Revise
More informationWhat is a Loop? Pretest Loops in C++ Types of Loop Testing. Count-controlled loops. Loops can be...
What is a Loop? CSC Intermediate Programming Looping A loop is a repetition control structure It causes a single statement or a group of statements to be executed repeatedly It uses a condition to control
More informationSection IV.1: Recursive Algorithms and Recursion Trees
Section IV.1: Recursive Algorithms and Recursion Trees Definition IV.1.1: A recursive algorithm is an algorithm that solves a problem by (1) reducing it to an instance of the same problem with smaller
More informationDecision Logic: if, if else, switch, Boolean conditions and variables
CS 1044 roject 3 Fall 2009 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 Dale/Weems text
More informationThe C++ Language. Loops. ! Recall that a loop is another of the four basic programming language structures
The C++ Language Loops Loops! Recall that a loop is another of the four basic programming language structures Repeat statements until some condition is false. Condition False True Statement1 2 1 Loops
More informationMATHEMATICAL INDUCTION. Mathematical Induction. This is a powerful method to prove properties of positive integers.
MATHEMATICAL INDUCTION MIGUEL A LERMA (Last updated: February 8, 003) Mathematical Induction This is a powerful method to prove properties of positive integers Principle of Mathematical Induction Let P
More information4/1/2017. PS. Sequences and Series FROM 9.2 AND 9.3 IN THE BOOK AS WELL AS FROM OTHER SOURCES. TODAY IS NATIONAL MANATEE APPRECIATION DAY
PS. Sequences and Series FROM 9.2 AND 9.3 IN THE BOOK AS WELL AS FROM OTHER SOURCES. TODAY IS NATIONAL MANATEE APPRECIATION DAY 1 Oh the things you should learn How to recognize and write arithmetic sequences
More informationTwo-way selection. Branching and Looping
Control Structures: are those statements that decide the order in which individual statements or instructions of a program are executed or evaluated. Control Structures are broadly classified into: 1.
More informationESCI 386 IDL Programming for Advanced Earth Science Applications Lesson 6 Program Control
ESCI 386 IDL Programming for Advanced Earth Science Applications Lesson 6 Program Control Reading: Bowman, Chapters 16 CODE BLOCKS A code block consists of several lines of code contained between a BEGIN
More information2) Based on the information in the table which choice BEST shows the answer to 1 906? 906 899 904 909
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ) Multiplying a number by results in what type of. even. 0. even.,0. odd..,0. even ) Based on the information in the table which choice BEST shows the answer to 0? 0 0 0 )
More information2 SYSTEM DESCRIPTION TECHNIQUES
2 SYSTEM DESCRIPTION TECHNIQUES 2.1 INTRODUCTION Graphical representation of any process is always better and more meaningful than its representation in words. Moreover, it is very difficult to arrange
More informationElementary Number Theory and Methods of Proof. CSE 215, Foundations of Computer Science Stony Brook University http://www.cs.stonybrook.
Elementary Number Theory and Methods of Proof CSE 215, Foundations of Computer Science Stony Brook University http://www.cs.stonybrook.edu/~cse215 1 Number theory Properties: 2 Properties of integers (whole
More informationChapter 5 Programming Statements. Chapter Table of Contents
Chapter 5 Programming Statements Chapter Table of Contents OVERVIEW... 57 IF-THEN/ELSE STATEMENTS... 57 DO GROUPS... 58 IterativeExecution... 59 JUMPING... 61 MODULES... 62 Defining and Executing a Module....
More informationDebugging. Common Semantic Errors ESE112. Java Library. It is highly unlikely that you will write code that will work on the first go
Debugging ESE112 Java Programming: API, Psuedo-Code, Scope It is highly unlikely that you will write code that will work on the first go Bugs or errors Syntax Fixable if you learn to read compiler error
More informationJavaScript: Control Statements I
1 7 JavaScript: Control Statements I 7.1 Introduction 2 The techniques you will learn here are applicable to most high-level languages, including JavaScript 1 7.2 Algorithms 3 Any computable problem can
More informationCOMS 4115 Programming Languages and Translators Fall 2013 Professor Edwards. Lullabyte
COMS 4115 Programming Languages and Translators Fall 2013 Professor Edwards Lullabyte Stanley Chang (cc3527), Louis Croce (ljc2154), Nathan Hayes-Roth (nbh2113), Andrew Langdon (arl2178), Ben Nappier (ben2113),
More informationPassing 1D arrays to functions.
Passing 1D arrays to functions. In C++ arrays can only be reference parameters. It is not possible to pass an array by value. Therefore, the ampersand (&) is omitted. What is actually passed to the function,
More informationThe Euclidean Algorithm
The Euclidean Algorithm A METHOD FOR FINDING THE GREATEST COMMON DIVISOR FOR TWO LARGE NUMBERS To be successful using this method you have got to know how to divide. If this is something that you have
More informationCOMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012
Binary numbers The reason humans represent numbers using decimal (the ten digits from 0,1,... 9) is that we have ten fingers. There is no other reason than that. There is nothing special otherwise about
More informationFigure 1: Graphical example of a mergesort 1.
CSE 30321 Computer Architecture I Fall 2011 Lab 02: Procedure Calls in MIPS Assembly Programming and Performance Total Points: 100 points due to its complexity, this lab will weight more heavily in your
More informationIntroduction to Python
Caltech/LEAD Summer 2012 Computer Science Lecture 2: July 10, 2012 Introduction to Python The Python shell Outline Python as a calculator Arithmetic expressions Operator precedence Variables and assignment
More informationParallel and Distributed Computing Programming Assignment 1
Parallel and Distributed Computing Programming Assignment 1 Due Monday, February 7 For programming assignment 1, you should write two C programs. One should provide an estimate of the performance of ping-pong
More informationSolving Rational Equations
Lesson M Lesson : Student Outcomes Students solve rational equations, monitoring for the creation of extraneous solutions. Lesson Notes In the preceding lessons, students learned to add, subtract, multiply,
More informationEuclidean Minimum Spanning Trees Based on Well Separated Pair Decompositions Chaojun Li. Advised by: Dave Mount. May 22, 2014
Euclidean Minimum Spanning Trees Based on Well Separated Pair Decompositions Chaojun Li Advised by: Dave Mount May 22, 2014 1 INTRODUCTION In this report we consider the implementation of an efficient
More informationSection 3-3 Approximating Real Zeros of Polynomials
- Approimating Real Zeros of Polynomials 9 Section - Approimating Real Zeros of Polynomials Locating Real Zeros The Bisection Method Approimating Multiple Zeros Application The methods for finding zeros
More information1 Description of The Simpletron
Simulating The Simpletron Computer 50 points 1 Description of The Simpletron In this assignment you will write a program to simulate a fictional computer that we will call the Simpletron. As its name implies
More informationOutline. Conditional Statements. Logical Data in C. Logical Expressions. Relational Examples. Relational Operators
Conditional Statements For computer to make decisions, must be able to test CONDITIONS IF it is raining THEN I will not go outside IF Count is not zero THEN the Average is Sum divided by Count Conditions
More informationChapter 2: Elements of Java
Chapter 2: Elements of Java Basic components of a Java program Primitive data types Arithmetic expressions Type casting. The String type (introduction) Basic I/O statements Importing packages. 1 Introduction
More informationCS 241 Data Organization Coding Standards
CS 241 Data Organization Coding Standards Brooke Chenoweth University of New Mexico Spring 2016 CS-241 Coding Standards All projects and labs must follow the great and hallowed CS-241 coding standards.
More informationPROGRAMMING IN C PROGRAMMING IN C CONTENT AT A GLANCE
PROGRAMMING IN C CONTENT AT A GLANCE 1 MODULE 1 Unit 1 : Basics of Programming Unit 2 : Fundamentals Unit 3 : C Operators MODULE 2 unit 1 : Input Output Statements unit 2 : Control Structures unit 3 :
More informationCS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013
Oct 4, 2013, p 1 Name: CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013 1. (max 18) 4. (max 16) 2. (max 12) 5. (max 12) 3. (max 24) 6. (max 18) Total: (max 100)
More informationLINEAR INEQUALITIES. Mathematics is the art of saying many things in many different ways. MAXWELL
Chapter 6 LINEAR INEQUALITIES 6.1 Introduction Mathematics is the art of saying many things in many different ways. MAXWELL In earlier classes, we have studied equations in one variable and two variables
More informationCOLLEGE ALGEBRA. Paul Dawkins
COLLEGE ALGEBRA Paul Dawkins Table of Contents Preface... iii Outline... iv Preliminaries... Introduction... Integer Exponents... Rational Exponents... 9 Real Exponents...5 Radicals...6 Polynomials...5
More informationPositional Numbering System
APPENDIX B Positional Numbering System A positional numbering system uses a set of symbols. The value that each symbol represents, however, depends on its face value and its place value, the value associated
More informationGamma Distribution Fitting
Chapter 552 Gamma Distribution Fitting Introduction This module fits the gamma probability distributions to a complete or censored set of individual or grouped data values. It outputs various statistics
More informationThis unit will lay the groundwork for later units where the students will extend this knowledge to quadratic and exponential functions.
Algebra I Overview View unit yearlong overview here Many of the concepts presented in Algebra I are progressions of concepts that were introduced in grades 6 through 8. The content presented in this course
More informationBoolean Algebra. Boolean Algebra. Boolean Algebra. Boolean Algebra
2 Ver..4 George Boole was an English mathematician of XIX century can operate on logic (or Boolean) variables that can assume just 2 values: /, true/false, on/off, closed/open Usually value is associated
More informationFundamentals of Programming
Fundamentals of Programming Introduction to the C language Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa February 29, 2012 G. Lipari (Scuola Superiore Sant Anna) The C language
More informationCHM 579 Lab 1: Basic Monte Carlo Algorithm
CHM 579 Lab 1: Basic Monte Carlo Algorithm Due 02/12/2014 The goal of this lab is to get familiar with a simple Monte Carlo program and to be able to compile and run it on a Linux server. Lab Procedure:
More informationTutorial on C Language Programming
Tutorial on C Language Programming Teodor Rus rus@cs.uiowa.edu The University of Iowa, Department of Computer Science Introduction to System Software p.1/64 Tutorial on C programming C program structure:
More informationAnalysis of Binary Search algorithm and Selection Sort algorithm
Analysis of Binary Search algorithm and Selection Sort algorithm In this section we shall take up two representative problems in computer science, work out the algorithms based on the best strategy to
More information2.3 WINDOW-TO-VIEWPORT COORDINATE TRANSFORMATION
2.3 WINDOW-TO-VIEWPORT COORDINATE TRANSFORMATION A world-coordinate area selected for display is called a window. An area on a display device to which a window is mapped is called a viewport. The window
More informationAn Introduction to Number Theory Prime Numbers and Their Applications.
East Tennessee State University Digital Commons @ East Tennessee State University Electronic Theses and Dissertations 8-2006 An Introduction to Number Theory Prime Numbers and Their Applications. Crystal
More informationLesson/Unit Plan Name: Patterns: Foundations of Functions
Grade Level/Course: 4 th and 5 th Lesson/Unit Plan Name: Patterns: Foundations of Functions Rationale/Lesson Abstract: In 4 th grade the students continue a sequence of numbers based on a rule such as
More information2.6 Exponents and Order of Operations
2.6 Exponents and Order of Operations We begin this section with exponents applied to negative numbers. The idea of applying an exponent to a negative number is identical to that of a positive number (repeated
More informationThe While Loop. Objectives. Textbook. WHILE Loops
Objectives The While Loop 1E3 Topic 6 To recognise when a WHILE loop is needed. To be able to predict what a given WHILE loop will do. To be able to write a correct WHILE loop. To be able to use a WHILE
More information1 3 4 = 8i + 20j 13k. x + w. y + w
) Find the point of intersection of the lines x = t +, y = 3t + 4, z = 4t + 5, and x = 6s + 3, y = 5s +, z = 4s + 9, and then find the plane containing these two lines. Solution. Solve the system of equations
More information6 EXTENDING ALGEBRA. 6.0 Introduction. 6.1 The cubic equation. Objectives
6 EXTENDING ALGEBRA Chapter 6 Extending Algebra Objectives After studying this chapter you should understand techniques whereby equations of cubic degree and higher can be solved; be able to factorise
More informationBeginning to Program Python
COMP1021 Introduction to Computer Science Beginning to Program Python David Rossiter Outcomes After completing this presentation, you are expected to be able to: 1. Use Python code to do simple text input
More informationOutput: 12 18 30 72 90 87. struct treenode{ int data; struct treenode *left, *right; } struct treenode *tree_ptr;
50 20 70 10 30 69 90 14 35 68 85 98 16 22 60 34 (c) Execute the algorithm shown below using the tree shown above. Show the exact output produced by the algorithm. Assume that the initial call is: prob3(root)
More informationMathematics, Basic Math and Algebra
NONRESIDENT TRAINING COURSE Mathematics, Basic Math and Algebra NAVEDTRA 14139 DISTRIBUTION STATEMENT A: Approved for public release; distribution is unlimited. PREFACE About this course: This is a self-study
More informationReading Input From A File
Reading Input From A File In addition to reading in values from the keyboard, the Scanner class also allows us to read in numeric values from a file. 1. Create and save a text file (.txt or.dat extension)
More informationUnit 3 Boolean Algebra (Continued)
Unit 3 Boolean Algebra (Continued) 1. Exclusive-OR Operation 2. Consensus Theorem Department of Communication Engineering, NCTU 1 3.1 Multiplying Out and Factoring Expressions Department of Communication
More informationMULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.
Exam Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) The JDK command to compile a class in the file Test.java is A) java Test.java B) java
More informationSimplification of Radical Expressions
8. Simplification of Radical Expressions 8. OBJECTIVES 1. Simplify a radical expression by using the product property. Simplify a radical expression by using the quotient property NOTE A precise set of
More information1.3 Polynomials and Factoring
1.3 Polynomials and Factoring Polynomials Constant: a number, such as 5 or 27 Variable: a letter or symbol that represents a value. Term: a constant, variable, or the product or a constant and variable.
More informationUnit 6. Loop statements
Unit 6 Loop statements Summary Repetition of statements The while statement Input loop Loop schemes The for statement The do statement Nested loops Flow control statements 6.1 Statements in Java Till now
More information