6 Pages

Lab_8

Course: ECS 102, Fall 2008
School: Syracuse
Rating:
 
 
 
 
 

Word Count: 937

Document Preview

102 Lab ECS 8 October 19/20, 2004 Anywhere that I ask you to observe what happens, write down your observations in the space provided. "'I wonder if I've been changed in the night? Let me think: was I the same when I got up this morning? I almost think I can remember feeling a little different. But if I'm not the same, the next question is 'Who in the world am I?' Ah, that's the great...

Register Now

Unformatted Document Excerpt

Coursehero >> New York >> Syracuse >> ECS 102

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
102 Lab ECS 8 October 19/20, 2004 Anywhere that I ask you to observe what happens, write down your observations in the space provided. "'I wonder if I've been changed in the night? Let me think: was I the same when I got up this morning? I almost think I can remember feeling a little different. But if I'm not the same, the next question is 'Who in the world am I?' Ah, that's the great puzzle!'" - Alice in Wonderland by Lewis Caroll I. Enter this program: /* lab8.c */ #include<stdio.h> #include<math.h> /*for fabs */ /*function prototypes*/ void printparts( double num ); int main(void) { double a=5.3, b=-87.34, c=0; printf("%f\n", a); printparts( a); printf("\n%f\n", b); printparts(b); printf("\n%f\n",c); printparts(c); return(0); } /* Separates a number into three parts: a sign ( +, -, or blank) a whole number magnitude a fractional part magnitude Example: -4.25 has sign - , whole number magnitude 4, fractional part magnitude .25 This function prints the three parts on three separate lines. */ /*********printparts**************/ void printparts( double num ) { char sign; int whole; double frac; double magnitude; /*local variable - magnitude of num*/ /* Determine sign of num */ if (num < 0) sign = '-'; else if (num == 0) sign = ' '; else sign = '+'; /* Finds magnitude of num and separates it into whole and fractional parts. */ magnitude = fabs(num); whole = floor(magnitude); frac = magnitude - whole; /*prints the output to the monitor*/ printf("sign: %c\nwhole number magnitude:",sign); printf("%d\nfractional part: %.2f\n", whole, frac); } By this time you shuold be comfortable with the correspondence of parameters in a function definition and arguments in a function call. In this program, list the parameters of printparts and the corresponding arguments in each function call: arguments parameters What in main corresponds to sign in the function? Whar in main corresponds to whole in the function? Draw all the variables and their values in the memory for main and in the memory for printparts for each time it is called: main printparts (first call) printparts (second call) printparts (third call) II. Modify your program so it looks like the following. You will notice that separate looks a lot like printparts, so do some cut and paste. Pay special attention to variables with asterisks in front of them in separate, like *whole, and variables with ampersands in front of them like &w in the function calls in main. Run the program. #include<stdio.h> #include<math.h> /*for fabs */ /*function prototypes*/ void separate( double num, char *sign, int *whole, double *frac); int main(void) { double a=5.3, b=-87.34, c=0; char s; /* *sign will store the sign here */ int w; /* *whole will store the whole magnitude here */ double f; /* *frac will store the fractional part here */ printf("%f\n", a); separate( &s, a, &w, &f); printf("%5c%5d%9.2f", s, w, f); printf("\n%f\n", b); separate( b, &s, &w, &f); printf("%5c%5d%9.2f", s, w, f); printf("\n%f\n",c); separate( c, &s, &w, &f); printf("%5c%5d%9.2f", s, w, f); return(0); } /*****************separate******************* /* Separates a number into three parts: a sign ( +, -, or blank) a whole number magnitude a fractional part magnitude Example: -4.25 has sign - , whole number magnitude 4, fractional part magnitude .25 This function shares the three parts with variables in main. */ void separate( double num, char *sign, int *whole, double *frac) { double magnitude; /*local variable - magnitude of num*/ /* Determine sign of num */ if (num < 0) *sign = '-'; else if (num == 0) *sign = ' '; else *sign = '+'; /* Finds magnitude of num and separates it into whole and fractional parts. */ magnitude = fabs(num); *whole = floor(magnitude); *frac = magnitude - *whole; /* nothing printed in this function */ } List the parameters of separate and the corresponding arguments in each function call. Include the * and & where they appear: arguments parameters The variables with * in front are pointers. Technically, they hold the address of another memory location. In practice, when they have the * in front, they are referring to the value in that memory location, so they are "aliases" (extra names) for a memory location that already exists. We use them to share memory with (not just copy the values from) main. Here is a picture for the first call to separate. Fill in the values. main a b c s w f When the function is finished, the memory on the right disappears, but the new values in s, w, and f tha...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Syracuse - ECS - 102
inputsdouble rad; /*radius of the circular window */double lW; /* length of the window */double wW; /* width of the window */double lH; /* length of the house */double hH; /* height of the house */outputsdouble pA; /* area of house without w
Syracuse - CPS - 196
/* arrayscope.c *//* demonstrates a function that assigns to an array parameter */#include &lt;stdio.h&gt;/* function prototypes */void clearArray (int values[], int numberOfElements);void notClearValue (int value);int main ( ){/* declare an
Syracuse - CPS - 196
/* datestructure.c *//* This program demonstrates the use of structures with a date structure *//* The date structure definition is similar to the one in the text, chapter 9, except that it uses integers to represent the months */#include &lt;st
Syracuse - CPS - 196
/* userand.c */#include&lt;stdio.h&gt; /* printf */#include&lt;stdlib.h&gt; /*rand, srand, RAND_MAX*/#include&lt;time.h&gt; /* time */int main(void){ int i; /* print some integer random numbers by calling rand */ printf(&quot;Some random numbers\n&quot;);
Syracuse - CPS - 196
/* coinstructure.c *//* This program converts the name of a U.S. coin to the number of cents that it is worth, and vice versa. *//* It uses an array of coin structures to store the coin names and values. */#include &lt;stdio.h&gt;#include &lt;string.h&gt;#d
Syracuse - CPS - 196
/*paramexamples.c*/ /* demonstrate the function calls to two functions */#include&lt;stdio.h&gt; /* function prototypes */ void repeatnumber(int x); void doublenumber(int y);int main(void) { /* variable declarations */ int anyint; /
Syracuse - CPS - 196
/* coinarray.c *//* This program converts the name of a U.S. coin to the number of cents that it is worth, and vice versa. *//* It uses two parallel arrays to store the coin names and values. */#include &lt;stdio.h&gt;#include &lt;string.h&gt;#define LENGTH
Syracuse - CPS - 196
/* squareroot.c *//* demonstrates the Newton-Raphson method to compute the square root, adapted from the example in the text starting on page 131 */#include &lt;stdio.h&gt;/* function prototypes */double absoluteValue (double x);double
Syracuse - CPS - 196
/*returnexamples.c*/ /* demonstrate the function calls to functions with return values*/#include&lt;stdio.h&gt; /* function prototypes */ char tell_nextletter(char c); char getletter(int m);int main(void) { /* variable declarations */ ch
Syracuse - CPS - 196
/* The Welcome Message Program *//* * Prints a text string as output. */ /* tells the compiler to use the standard I/O functions, including printf */ #include &lt;stdio.h&gt; /* the main function is always called main - it returns an integer
Syracuse - CPS - 196
/*paintwall.c*/ /* computing the surface to paint on a wall, using two functions*/#include&lt;stdio.h&gt; /* function prototypes */ double ComputeRectArea(double height, double length); double ComputeCircleArea(double radius);int main(void) {
Syracuse - CPS - 196
/* tictactoeboard.c *//* This program uses a 2-D array to hold the values of a tic-tac-toe board, using the characters ' ' (space) for the empty space, and 'X' and 'O' for the X's and O's. This program displays an example board, but it doe
Syracuse - CPS - 196
/* reversearray.c *//* This program reads an array from a file and calls a function, reverse, to reverse the elements of the array.*/#include &lt;stdio.h&gt;#define sentinel 1000#define MAX_ARRAY 100/* function prototypes */void reverse (int va
Syracuse - CPS - 196
/* shufflesort.c *//* Program to demonstrate sorting an array of integers, using a shuffle sort algorithm. From the text by Kochan in chapter 8 */#include &lt;stdio.h&gt;void sort (int values[ ], int numberOfElements);void printarray (int values[
Syracuse - CPS - 196
/* drawing.c */#include&lt;stdio.h&gt;#include&lt;string.h&gt;/* defined constants */#define WIDTH 40 /* width of buffer: only WIDTH-2 available for drawing*/ #define HEIGHT 10 /* height of buffer *//* function prototypes */void c
Syracuse - YXU - 06
PROCEEDINGS OF THE AMERICAN MATHEMATICAL SOCIETY Volume 129, Number 6, Pages 18611872 S 0002-9939(00)05966-9 Article electronically published on December 7, 2000SUBDIVISION SCHEMES FOR ITERATED FUNCTION SYSTEMSCHARLES A. MICCHELLI, THOMAS SAUER, A
Syracuse - YLU - 08
MCS 320Introduction to Symbolic ComputationSpring 20033. Making Plots with MATLAB3.1 Basic PlottingSuppose we want to plot the function y = sin(x), over the interval [-, ]. First we have to sample points from this function, say at evenly spac
Syracuse - YXU - 06
PROCEEDINGS OF THE AMERICAN MATHEMATICAL SOCIETY Volume 134, Number 9, September 2006, Pages 27192728 S 0002-9939(06)08315-8 Article electronically published on March 23, 2006THE BEDROSIAN IDENTITY FOR THE HILBERT TRANSFORM OF PRODUCT FUNCTIONSYUE
Syracuse - CHE - 686
Dihydroxylation of Alkenes: Diol Stereochemistry as a Function of MethodOsO4: stereospecific, syn addition from least hindered faceMe OH Me OHEpoxide opening: stereospecific, trans diaxial addition (SN 2)O OH OH H2O regiochemistry: under aci
Syracuse - CHE - 686
How to Request a Copy of the Aldrich Chemical Catalog 1. Go to the aldrich web site: http:/www.sigmaaldrich.com 2. Click on &quot;Support&quot; from the menu at the top (you may have to choose a country first) 3. Click on &quot;Request Literature&quot; 4. Choose the Ald
Syracuse - CHE - 686
Approaches to the Erythronolides OBR2 TBSOHO MeO R' R OR O O OH3 9HOO OOO OTBS Masamune 6-deoxyerythronolide B OH7O9O13OH OOHO TBSO9O OStork erythronolide AR O O1OH1R OH OH N O Schreiber 6-deoxyerythronolide B
Syracuse - CHE - 686
Pauson-Khand reaction: mechanismO C (CO) 3Co Co(CO) 3 C O(CO)3Co RCo(CO) 3 H- CO(CO)3Co RCo(CO) 2 HHR- 2 COR' (CO)3Co RR' Co(CO) 2 H + CO alkene insertion R' (CO)3Co (CO)3Co R H R' + (CO)3Co (CO)3Co R R' C - [Co 2(CO)6] R H (CO)
Syracuse - CHE - 686
Momilactone retrosynthetic analysis (Deslongchamps)CO2Me CO2Me H O O H O RO H MeO 2C RO MeO2C CO2Me CO2MeO + O A CO2Me CO2Me MeO B OR Diels-Alder diastereoselectivityCO2Me CO2Me E E MOMO (endo) E chair-boat-chair E E (endo) MOMO (exo) E E MOMO
Syracuse - CHE - 686
Indolizomycin Retrosynthetic Analysis (Danishefsky)OOH NO N TEOCOTBS O N TEOC CHO O NO O ORoseophilin Retrosynthetic Analysis (Frstner)MeO HCl Cl O + NH O N SEMMeO O Cl NHN HO TBSO PhO2S O O Br OH HO ClReserpineMeO N H H MeO
Syracuse - CHE - 686
Miscellaneous Polycyclic CompoundsMomilactone Deslongchamps J. Org. Chem. 2002, 67, 5269. Seychellene Piers J. Am. Chem. Soc. 1971, 93, 5113. Mirrington J. Org. Chem. 1978, 37, 1843. Jung J. Am. Chem. Soc. 1981, 103, 6677. Stork Tetrahedron Lett. 1
Syracuse - CSE - 607
CSE/CIS 607 Assessment Exam 01/17/08 NAME (print): SIGNATUREQuestion 1: Let f : X - Y be an injection (i.e. one-to-one). Prove that: there is a surjective (i.e. onto) function g : Y - X such that for all x X, g(f (x) = x. Since f is one-to-one, ea
Syracuse - CIS - 252
Lab 8: Higher-order Patterns for Processing ListsOverview This lab will give you some practice with Haskells higherorder functions map and filter. These generalize some idioms for list processing that weve already seen. Caveat: This lab is based on
Syracuse - CIS - 252
Homework 2: Circles and DiamondsCIS 252 C Introduction to Computer ScienceAdministrivia. This homework is ofcially due in the bin in CST 3-212 by You may also nd it useful to read the Notes section of this assignment noon on February 2. The follo
Syracuse - CIS - 252
Lab 6: Getting Started with Type Classes and Algrebraic Types1. IntroductionThis lab will give you some practice in working with Haskells type classes. When you introduce a new data type in Haskell, you often want to extend the meaning of old funct
Syracuse - CIS - 252
Homework 8: More on Higher-Order FunctionsCIS 252 = Introduction to Computer Sciencechanges [32,98,45,12,84] A DMINISTRIVIA . The homework is based on Chapter 9 of Thompson's HCFP. This homework is due in the bin in CST 3-212 by noon on Monshould
Syracuse - CIS - 252
Lab 9: More On Higher-order Functions 1. Functions as First-class ValuesIn Haskell, functions are rst-class values. This means that they have the same status as other values, such as integers, oating-point numbers, character strings, etc. This lab e
Syracuse - CIS - 252
Lab 5: Patterns for List ProcessingOverview. This lab gives you some practice with some common idioms for list processing. These idiomsmapping, ltering, and foldingare so common that Haskell (and most other functional programming languages) includes
Syracuse - CIS - 252
MONADIC I/O IN HASKELLCIS 252 - Spring 2008 Introduction to Computer ScienceThis is based on Chapter 18 of Thompson &amp; &quot;Tackling the Awkward Squad,&quot; by Simon Peyton Jones http:/research.microsoft.com/~simonpj/papers/marktoberdorf/THE CONFLICTH
Syracuse - CIS - 252
CIS 252 Introduction to Computer Science Spring 2008Course SyllabusJ ANUARY 14, 2008 Catalog Description Programming emphasizing recursion, data structures, and data abstraction. Elementary analysis of and reasoning about programs. Public policy
Syracuse - CIS - 252
SOME HISTORYAround 100 years ago there was of a lot of interest (and fuss) about the foundations of mathematics. General Worries: Q: How much of math can be formalized? Q: How much of math can be turned into a mere calculation? A specic problem: Hil
Syracuse - CIS - 252
Lab 1: Hello WorldThis lab will introduce you to some of the key tools we will be using in this course. In many labs, you are allowed to work together with a partner. However, this lab must be a solo effort since we'll be setting up your Unix accoun
Syracuse - CIS - 252
Homework 3: Yet More PicturesAdministriviaNotes This homework is based on the rst four chapters of Haskell: The Craft of Functional Programming (HCFP). You may use any code you want from the lectures. However, you should include a note in your comm
Syracuse - CIS - 252
Lab 4: Haskell List ComprehensionsOverview. In this lab you get to try out some of Haskell's basic mechanisms for defining lists. It is based on 5.4 and 5.5 of Thompson. You may work singly or in pairs on this lab.CIS 252 C Introduction to Compute
Syracuse - CIS - 252
Lab 3: Pictures of RecursionOverviewThis lab will give you practice with writing recursive functions in Haskell, using the Pictures module (http:/www.cis.syr.edu/courses/cis252/code/ Pictures.lhs) from Homework 1. Remember to include aimport Pictu
Syracuse - CIS - 252
Homework 6: Binary TreesAdministriviaThis homework is based on chapter 14 of Thompson, and requires you (as in: you lose lots of points if you don't) to follow the design recipe discussed in lecture. This homework is due in the bin in CST 3-116 by
Syracuse - CIS - 252
Homework 1 AdministriviaCoverage. This homework covers material in Chapters 1 &amp; 2 of Haskell: The Craft of Functional Programming (HCFP).CIS 252 C Introduction to Computer ScienceFirst, introduce the folowing Haskell denition:twoHorse : Picture
Syracuse - CIS - 252
Lab 2: Getting Familiar with Haskell &amp; HugsYou may work singly or in pairs on this lab.CIS 252 C Introduction to Computer ScienceFor more detail on Emacs than provided in this lab: Start up Emacs, go to Emacs's Help menu, select Emacs Tutorial, a
Syracuse - CIS - 252
Homework 10: Turing MachinesCIS 252 &lt; Introduction to Computer ScienceAdministrivia. This homework covers material from Chapter 31 of The For example, if the original input is &quot;abbab#abbab&quot;, the nal output should be &quot;Y&quot;; if the original input is
Syracuse - CIS - 453
SRS TOC0. TOC Main TOC 1. Introduction 1. Purpose 2. Scope 3. Definitions, acronyms, and abbreviations 4. References 5. Overview 2. General description 1. Product perspective 2. Product functions 3. User characteristics 4. Game objectives 5. General
Syracuse - CIS - 655
Sun Fire T2000 Server OverviewSun Microsystems, Inc. www.sun.comPart No. 819-2543-11 April 2006, Revision A Submit comments about this document at: http:/www.sun.com/hwdocs/feedbackCopyright 2006 Sun Microsystems, Inc., 4150 Network Circle, San
Syracuse - CIS - 554
Before function calls:a= 5 b= 10At end of badswap, before return:x= 10 y= 5After call to badswap:a= 5 b= 10At end of goodswap, before return:x= 10 y= 5After call to goodswap:a= 10 b= 5At end of badswap, before return:x= 50 y= 2Befor
Syracuse - SC - 504
Introduction to Programming in C+Class 8 02/12/2003 Rohit ValsakumarCharacter I/OAll data is input or output in the form of charactersIf the program expects a integer input then the character stream received from the input is automat
Syracuse - SC - 504
IntroductiontoProgramming inC+Class22 04/17/2003 RohitValsakumarMultipleInheritance Aclasscanbederivedfrommorethanoneclass Thisiscalledasmultipleinheritance ThesyntaxisasgivenbelowclassA /BaseclassA {. }; classB /BaseclassB { }; classC:public
Syracuse - SC - 196
CPS 196 Introduction to Computer Programming: CMemory, Addresses Function declarations Function calls scanf OverviewMemory Addresses Function declaration, call scanf MemoryPart of the computer that holds data and instructions
Syracuse - SC - 504
CIS504CIS 504 U001 Introduction to Programming: C+ Rohit Valsakumar sc504a@ecs.syr.edu SPRING 2003 Lab 11CIS5041CIS504LAB 11Overloading:Write a program that contains and does the following: A) Create a class called &quot;Complex&quot; for performi
Syracuse - SC - 504
CIS504CIS 504 U001 Introduction to Programming: C+ Rohit Valsakumar sc504a@ecs.syr.edu SPRING 2003 Lab 6CIS5041CIS504Complete the following program and make sure that every function works as expected Only a bare skeleton is provided for eac
Syracuse - SC - 196
LECTURE 5 DATA OUTPUTputchar FUNCTIONSingle characters can be displayed using the C library function putchar. The putchar function is complementary to the getchar function. The putchar transmits a single character to the standard output device. It
Syracuse - CSE - 773
(* file ~/public_html/cse773/README.txt, L. Morris, 1/8/03 *)This subdirectory of my public_html is intended to make relevant textualmaterial which I have written, and may want to revise from time to time,accessible to students in CSE 773, Spring
Wyoming - WYO - 4
Wyoming 4-H is.open to youths ages 8 to 19.Where to find Wyoming 4-H.County Albany Big Horn Campbell Carbon Converse Crook Fremont Goshen Hot Springs Johnson Laramie Lincoln Natrona Niobrara Park Platte Sheridan Sublette Sweetwater Teton Uinta Wa
Syracuse - JPTHOM - 01
TaxAppendixTable1.Topmarginalstateincometaxrateonwages1988 3.65 0 5.41 7 9.3 4.76 0 7.7 0 5.66 9 8.2 2.5 3.4 7.39 3.87 4.39 4.14 8 5 5 4.6 8 4.75 4.39 9.02 5.9 0 0 3.5 7.83 8.38 7 3.77 6.55 5.64 9 2.1 6.04 7 0 0 0 6.58 6.05 5.75 0 9.5 6.5 6.93 0 198
Syracuse - MAT - 121
Problems from Section 6-5 of the text-8. Find the margin of error: n = 777, x = 543, 90% confidence.12. Construct the confidence interval estimate of the population proportionp: n = 1200, x = 800, 90% confidence.16. Use the given information
Syracuse - MAT - 19
Problems from Section 6-5 of the text-8. Find the margin of error: n = 777, x = 543, 90% confidence.12. Construct the confidence interval estimate of the population proportionp: n = 1200, x = 800, 90% confidence.16. Use the given information
Syracuse - MAT - 121
Problems from section 4-4-6. Several students were unprepared for a multiple-choice quiz with 20questions, and all of their answers were guesses. Each question has five possible answers, and only one of them is correct.a. find the mean and sta
Syracuse - MAT - 121
Binomial Distribution Problem from Text-26)The rates of on-time flights for commercial jets are continuously trackedby the U.S.Department of Transportation. Recently, Southwest Air had thebest rate with 80% of its flights arriving on time. A tes
Syracuse - PHY - 312
PHY312 - Homework 31. An object of mass 3 kilograms moves 8 meters along the x-direction in in 3 108 secs as measured in the laboratory. What is its energy and momentum ? Its rest energy ? Its kinetic energy ? What value of the kinetic energy would
Syracuse - PHY - 101
Outline PHY 101 Lecture #9: Series Circuit, Parallel Circuit, and Capacitorshttp:/physics.syr.edu/courses/PHY101/ Off. Hrs: Tue 9:30 11:00, Physics 263-4 Prof. Schwarzs Problem Sessions: Mon and Tues, 5:15 6:15, Physics 202/2041. Series circuit 2