10 Pages

Review Test 2

Course: ME 205, Spring 2007
School: University of Texas
Rating:
 
 
 
 
 

Word Count: 660

Document Preview

2 Review Test Version C 1. Write a menu driven program that allows a user to specify matrices operation: add, subtract, multiply. The user should be able to enter the two matrices and choose the operation to be performed in the main function. Based upon user input, one of the functions must be called and the result must be displayed. #include <stdio.h> void add(int iaaMatrix1[2][2], int...

Register Now

Unformatted Document Excerpt

Coursehero >> Texas >> University of Texas >> ME 205

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.
2 Review Test Version C 1. Write a menu driven program that allows a user to specify matrices operation: add, subtract, multiply. The user should be able to enter the two matrices and choose the operation to be performed in the main function. Based upon user input, one of the functions must be called and the result must be displayed. #include <stdio.h> void add(int iaaMatrix1[2][2], int iaaMatrix2[2][2]); void subtract(int iaaMatrix1[2][2], int iaaMatrix2[2][2]); void multiply(int iaaMatrix1[2][2], int iaaMatrix2[2][2]); void add(int iaaMatrix1[2][2], int iaaMatrix2[2][2]) { int iaaMatrix3[2][2]; int i,j; for (i=0;i<2;i++) { for (j=0;j<2;j++) { iaaMatrix3[i][j] = iaaMatrix1[i][j]+iaaMatrix2[i][j]; } } printf("\nThe resulting matrix is:\n\n"); for (i=0;i<2;i++) { for (j=0;j<2;j++) { printf("%d\t",iaaMatrix3[i][j]); } printf("\n"); } } void subtract(int iaaMatrix1[2][2], int iaaMatrix2[2][2]) { int iaaMatrix3[2][2]; int i,j; for (i=0;i<2;i++) { for (j=0;j<2;j++) { iaaMatrix3[i][j] = iaaMatrix1[i][j]iaaMatrix2[i][j]; } } printf("\nThe resulting matrix is:\n\n"); for (i=0;i<2;i++) { for (j=0;j<2;j++) { printf("%d\t",iaaMatrix3[i][j]); } printf("\n"); } } void multiply(int iaaMatrix1[2][2], int iaaMatrix2[2][2]) { int iaaMatrix3[2][2]; int i,j,k; for(i=0;i<2;i++) { for(j=0;j<2;j++) { iaaMatrix3[i][j]=0; for(k=0;k<2;k++) { iaaMatrix3[i][j] += iaaMatrix1[i][k]*iaaMatrix2[k][j]; } } } printf("\nThe resulting matrix is:\n\n"); for (i=0;i<2;i++) { for (j=0;j<2;j++) { printf("%d\t",iaaMatrix3[i][j]); } printf("\n"); } } int main(void) { int int int int { for (j=0;j<2;j++) { printf("\nEnter the value for row %d column %d for matrix 1: ",i+1,j+1); scanf("%d",&iaaMatrix1[i][j]); i,j; iaaMatrix1[2][2]; iaaMatrix2[2][2]; iOperation; for (i=0;i<2;i++) } } for (i=0;i<2;i++) { for (j=0;j<2;j++) { printf("\nEnter the value for row %d column %d for matrix 2: ",i+1,j+1); scanf("%d",&iaaMatrix2[i][j]); } } do { printf("If you want to add matrices, enter 1. For subtraction enter 2 and for mulitplication enter 3\n"); scanf("%d",&iOperation); if (iOperation==1) iaaMatrix2); add(iaaMatrix1, else if(iOperation==2) subtract(iaaMatrix1, iaaMatrix2); else multiply(iaaMatrix1, iaaMatrix2); } while (iOperation<0 && iOperation>4); return(0); } 2. Calculation of Area under a Curve One of the applications of computers in numerical analysis is computing the area under a curve. One simple method of calculating the area under a curve is to divide the area into a number of trapezoids of same width and summing up the areas of individual trapezoids. The area of a trapezoid is given by Area = 0.5 * (h1 +h2) *b Where h1 and h2 are the heights of two sides and b is the width as shown below: Your program needs to calculate the area for a curve of the function: f(x) = x^4 +2x+ 10 between any two given limits, say, A and B. Write a function to calculate the value of f(x). Input: Lower limit (A) Upper limit (B) Number of trapezoids Output: Total area under the curve between the given limits An example output is: Area under a curve: Enter lower limit: 0 Enter upper limit: 3 Enter number of trapezoids: 30 Total AREA = ...... (where ...... indicates the final result) #include <stdio.h> #include <math.h> int main(void) { int i; float fTemp; float fLL, fUL; int iNoTrap; float fWidth; float fArea=0; printf("Input the lower limit: \n"); scanf("%f",&fLL); printf("Input the upper limit: \n"); scanf("%f",&fUL); printf("Input the number of trapezoids: \n"); scanf("%d",&iNoTrap); fWidth= (fUL-fLL)/ (float) iNoTrap; float float float float faHeight1[100]; faHeight2[100]; faHeightTot[100]; faAreaPerTrap[100]; printf("The lower limit is: %2.1f\n",fLL); printf("The upper limit is: %2.1f\n",fUL); printf("The number of trapezoids is: %d\n",iNoTrap); fTemp=fLL; for (i=0;i<=iNoTrap+1;i++) { faHeight1[i]=pow(fTemp,4)+(2*fTemp)+10; fTemp += fWidth; } fTemp=fLL+fWidth; for (i=0;i<=iNoTrap+1;i++) { faHeight2[i]=pow(fTemp,4)+(2*fTemp)+10; fTemp += fWidth; } for (i=0;i<iNoTrap;i++) faHeightTot[i]=faHeight1[i]+faHeight2[i]; for (i=0;i<iNoTrap;i++) faAreaPerTrap[i]=0.5*fWidth*faHeightTot[i]; for (i=0;i<iNoTrap;i++) fArea += faAreaPerTrap[i]; printf("The total area is: %3.2f",fArea); return(0); }
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:

University of Texas - SOC - W302
Stratification -structured systems of inequality -unequal distribution of good things in life -present in all known human societies -Dimensions of stratification vary: -degree of inequality present varies dramatically (sometimes intense/minimal) -wor
Michigan State University - LBS - 118
University of Texas - SOC - W302
GenderDistinction between sex and gender: -sex is biological -gender refers to cultural, including psychological, differences (that are observed) between man and woman Culture and biology interact to form gender roles Genderwhat are expectations of
University of Texas - SOC - W302
Race and Ethnicity -why is it important for a globalizing eco/world? -no longer bounded groups Some of things globalization causing in regards to Racial/Ethnic Diversity: 1) as people migrate and emigrate, we find a degree of diversity increasing 2)
University of Texas - SOC - W302
Body Art as a Visual Language Body art transmits meanings, from ideals of beauty, important life transitions, and religious epics to social status and personal rebellion Body art communicates a person's status in society, displays accomplishments and
University of Texas - ECON - W304
CHAPTER 10Production and Costs (ch 10) - Long-run costs: - LRATC curve and plant size - Regions: economies of scale, constant returns to scale, diseconomies of scale - factors - mergers and scale economiesLook at notes (graph of plant sizes and LR
University of Texas - ME - 326
Answers to Examples:2.3.4.End of 2.2.1-4 ExamplesSolutions to Examples:6.7.8.End of Examples 2.2.5-8
University of Texas - ME - 205
Version F 1. Indicate whether the following statements are true (T) or false (F): a. An Array is a group of values having a common variable name and all of the same data type. TRUE b. The subscript (or index) identifies the location of a particular e
University of Texas - M - 427K
University of Texas - GOV - 312L
ROOSEVELT 1. Historical Background -America began as a pioneering community -pioneering conditions accentuated vices and virtues: energy and ruthlessness, all the good qualities and all the defects of an intense individualism, self-reliant, self-cent
University of Texas - GOV - 312L
SOLZHENITYSN 1. Decline in Courage -the U.S. has &quot;lost its civic courage&quot; -noticeable among the ruling and intellectual elites, which causes the impression of a loss of courage by the entire society -those who are courageous, however, have no influen
University of Texas - ME - 205
Unit Test 1 1. #include &lt;stdio.h&gt; int main(void) { printf(&quot;This is my first program for the Unit 01 Readiness Test.&quot;); return (0); } 2. /* This is the second question */ #include &lt;stdio.h&gt; #define PI 3.1415926 #define THREE 3.0 #define TWO 2.0 int ma
University of Texas - ME - 205
Unit 2 Readiness Test B 1. #include &lt;stdio.h&gt; #include &lt;math.h&gt; int main(void) { float fYears; float fPrinciple; float fSI; float fRate; printf(&quot;Please input the Principle:&quot;); scanf(&quot;%f&quot;, &amp;fPrinciple); printf(&quot;Please input the Simple Interest:&quot;); sca
University of Texas - ME - 205
Unit 3 Readiness Test Version A 1. #define PI 3.14159 main() { int R, C; /*R-Radius of circle */ float perimeter; /*Circumference of circle */ float area; /*area of circle */ C = PI R = 5; Perimeter = 2.0 *C *R; Area = C*R*R; Printf(&quot;%f&quot;, &quot;%d&quot;, &amp;peri
University of Texas - ME - 205
Unit 4 Readiness Test D 1. (a) (b) (c) (d) (e) 2. 1) 17 2) 11 3) 6 3. #include &lt;stdio.h&gt; int main(void) { float fT; printf(&quot;Input the temperature:\n&quot;); scanf(&quot;%f&quot;,&amp;fT); if (fT&gt;75.0) printf(&quot;too hot&quot;); else if (fT&lt;70.0) printf(&quot;too cold&quot;); else printf
University of Texas - ME - 205
Unit 6 Readiness Test Version B 1) This program will print: first 1 2 5 second 7 2.0 6 third 7 2 5 2) #include &lt;stdio.h&gt; #include &quot;header1.h&quot; #include &quot;header2.h&quot; #include &quot;header3.h&quot; int main(void) { float fX = getfX(); equation1(fX); equation2(fX);
University of Texas - ME - 205
Unit 07 Readiness Test Version B1. The following questions test your understanding of arrays. Please identify if the following statements are right or wrong. Explain why. 1) int a[3] = {0, 2, 2, 3, 4} ; wrong: the array is defined to have 3 values b
University of Texas - ME - 205
Unit 08 Readiness Test Version CNote: To turn in the answers for grading, you have to copy your commands and the corresponding answers from the Matlab command window and paste it into a Word Document. 1. Define 4 variables a,b,c,d as the height of
University of Texas - ME - 205
Unit 09 Readiness Test Version AUnit 09 Readiness Test1. Create a matrix A with non-zero elements and then figure out the sum of the eigen values of the matrix using the trace() command. Verify your answer by printing the eigen values using the a
University of Texas - ME - 205
Unit 10 Readiness Test DNote: All Programs have to be submitted as m-files pasted in a word doc or text file1. Create a function that has three inputs x, y and o. Based on the value of o determine the oth root and the oth power of x and y. Hint: Y
University of Texas - ME - 205
Unit 11 Readiness Test Version B1. Write a simple java application that will run on your computer as a stand alone application. The program should print out greeting: &quot;Wow, this is my first java program!&quot; class TrivialApplication { public static voi
University of Texas - ME - 205
Unit 13 Readiness Test Version DAnswer following questions: 1. a. Explain carefully what the destroy() method does. The destroy() method is called after the stop() method in order to free up all the resources that are being held. b. What is a Graph
University of Texas - M - 427K
M427K - FinalMay 7, 2007Linear Equations Method of Integrating Factors y + p(t)y = q(t) (y) (t)q(t)dt + C (t) (t) = ep(t)dt= (t)q(t) y(t) = Separable Equations When the ODE can be framed in the following form: y dy g(y) dy g(y) = f (t)
Michigan State University - LBS - 133
Evolving Monsters In the late nineteenth century, the growth of experimental medical science transformed the American medical profession in a plethora of ways. As science and medicine began to progress in a more complex and rapid manner the image of
Michigan State University - KIN - 216
KIN 216 Applied Human AnatomyChapter 7Axial SkeletonSkeleton, in generalBones, cartilages, joints (articulations), ligaments 206 bonesAxial skeleton 80 bones Skull Vertebral column Thoracic cage Upper and lower limbs Pectoral and p
Michigan State University - KIN - 216
KIN 216 Applied Human AnatomyChapter 8Appendicular SkeletonLimb bones and girdlesPectoral girdle: attaches upper limbs to trunk Pelvic girdle: attaches lower limbs to trunkAttached to axial skeleton Each limb is composed of 3 basic segmen
Michigan State University - KIN - 216
KIN 216 Applied Human AnatomyChapter 9ArticulationsArthro (Gr.) = joint Articulations and skeletal contractions allow movement Arthrology = the study of joints Arthralgia: pain in joints Joints are classified by function or structure Functio
Michigan State University - KIN - 216
KIN 216Chapter 11Rigor MortisAffects skeletal muscle tissue several hours after death Depletion of ATP in muscle fibers causes stiffness of joints Crossbridges are stuck in bound position because there is no ATP to release themLever SystemsLev
Michigan State University - KIN - 216
KIN 216Chapter 12Nervous System THE master control and communications center in the body Communication occurs via electrical signals Three overlapping functions Sensory receptors monitor changes Integration (processing and interpreting) Res
University of Texas - ECON - 304K
CHAP 13 Monopolistic competitionOlivier Giovannoni 304K: Introduction to MicroeconomicsNov. 5, 2005CHAP 13- Monopolistic competition 2Outline1.What is monopolistic competition?(p;Q) in monopolistic competition Product development and mark
University of Texas - SOC - 308
Acts of devotion- religious practices are often designed to draw a people closer to the ideals of a faith by reminding them of their Gods, their values and the principles of their faith as well as important events and figures of their shared history.
University of Texas - ASE - 324L
ASE 324L Laboratory #5 High Temperature Creep and Creep RuptureAmber Mueller February 28, 20081. a)Creep-Time Curve0.6 0.5Unit Creep Strain0.4 0.3 0.2 0.1 0 0 200 400 600Time (hours)3000 5000 8000 1100080010001200b) slope = change
University of Texas - ASE - 324L
University of Texas - HDF - 304
3/18/08 Follow-up Questions 1. Marriage license and courses - Starting sept '08 waive license fee and no cost of class. - 8 hours of premarital instruction - specific type TBD - future website &quot;Twogether in Texas&quot; 2. Prenuptial agreements and mari
University of Texas - GOV - 310L
Government Chapter 2 The Constitution1. The Declaration of Independence: a. The Second Continental Congress submitted the Declaration of Independence on July 4, 1776; written predominantly by Thomas Jefferson i. Human beings have rights that can't b
University of Texas - GOV - 310L
Government Chapter 4 Structural Foundations of American Government and Politics1. America's Population a. Since the first census in 1790 millions of immigrants have migrated to the U.S. b. Nativist: Antiforeign; applied to political movements active
University of Texas - GOV - 310L
Government Chapter 5 Public Opinion1. Core Beliefs: Individual's views about the fundamental nature of human beings, society, and economy; taken together, they compromise the political clture 2. Political Attitudes: Individual's views about public p
University of Texas - CH - 310N
NAME (Print): _ SIGNATURE: _Chemistry 310N Dr. Brent Iverson 1st Midterm Feb. 22, 2007Please print the first three letters of your last name in the three boxesPlease Note: This test may be a bit long, but there is a reason. I would like to give
Michigan State University - LBS - 118
PRACTICE COPY 1 LBS 118EXAM #4SHOW ALL WORK BY HANDName: TA Name:FIND THE FOLLOWING INTEGRALS:1.4 x 2 3x 2 dx x( x 1)( x 2)4.4 x26 dx 24 x 452.csc2 x cot 2 x dx csc2 2 x4x3 cos2xdx5.2 x2 x 5 dx 2x 33.6.1 2 x2 ln x dx x
Michigan State University - LBS - 118
Michigan State University - FRN - 201
Nom du film: Le Fabuleus destin d'Amlie Poulain Le liste des personnages principaux: Audrey Tautou : Amlie Poulain Mathieu Kassovitz : Nino Quincampoix Rufus : Raphal Poulain, le pre d'Amlie Serge Merlin : Raymond Dufayel Jamel Debbouze : Lucien Yola
Michigan State University - FRN - 201
Ma Voyage Paris!Je suis alle Paris fvrier dernier pour le patinage. Ma soeur et ma mre sont alles avec moi en me regardant patiner. Cependant, quand je ne patinais pas je pouvais explorer la ville magnifique de Paris! Je pense que le climat tait
Michigan State University - LBS - 144
CH1: Biology and the Tree of Life1.1 The Cell Theory1.2 The Theory of Evolution by Natural Selection1.3 The Tree of Life Linnaean Taxonomy Intro Phylogeny Using Molecules to Understand the Tree of Life 1.4 Doing Biology Hypothesis Testing Experi
Michigan State University - LBS - 144
CH 11: The Cell Cycle1. 2. 3. 4. Intro Mitosis and the cell cycle How does mitosis take place? Control (or no control) of the cell cycleStarting Small: Biochemistry Major biochemical molecules: What are the key molecules that make up your body?
Michigan State University - LBS - 144
CH 12: Meiosis OUTLINEI. Review/introduction II. Meiosis III. Genetic variation IV. Breakdowns in meiosisCopyright 2004 Pearson Education, Inc. publishing as Benjamin CummingsREVIEW OF MITOSISCell division!Growth, repair, asexual reproduction
Michigan State University - LBS - 144
CH 13 Part 1: Mendel and the gene OUTLINEI. Lots of vocab II. Mendel's experiments &amp; model III. Predicting genotypes &amp; phenotypesChromosome theory of inheritancemeiosis causes patterns of inheritance caused by genes on chromosomesSOME VOCAB Gen
Michigan State University - LBS - 144
CH 13: Mendel and the geneWhere we've been so far. 1. Genetics vocab 2. Mendel's experiments 3. Mendel's principles of segregation &amp; independent assortmentWhere we're going.1. 2. 3. 4. Predicting genotypes and phenotypes Mendel's contributions to
Michigan State University - LBS - 144
CH 13: Mendel and the geneLast Thursday.1. 2. 3. 4. Predicting genotypes and phenotypes Mendel's contributions to genetics Chromosomal theory of inheritance Testing and extending the chromosome theoryToday.1. Sex linkage &amp; gene linkage 2. Exten
Michigan State University - LBS - 144
The Questions included in this session are:1. How does the word theory in science differ from its use in everyday English? A. There is no difference - the terms are interchangeable. B. All scientific theories have stood the test of time. C. Scientif
Michigan State University - LBS - 144
&quot;Medical Tourism&quot;The phenomenon of &quot;medical tourism&quot; is becoming a widespread practice for most Americans. Medical tourism is the practice of a patient &quot;outsourcing&quot; healthcare services to an area outside of his/her home country. Last year alone Am
Michigan State University - LBS - 144
&quot;The NDR1- Actin Connection: The Actin Cytoskeleton as a Virulence Target in Gene-for-Gene Resistance&quot; The molecular basis of plant-pathogen interactions are resistance (at the cellular level) and susceptibility. The role of actin in plant defense si
Michigan State University - LBS - 144
The 11th Hour The environment will survive global warming-it's the people that will not. The biosphere is in trouble, it is sick; the earth's crust has an infection that needs to be addressed. As humans destroy nature, we are ultimately destroying ou
Michigan State University - LBS - 144
Molecular Ecology and Systematic of the Dusky Dolphin (Lagenorhynchus Obscurus)The Dusky Dolphin is part of the genus Lagenorhynchus. The genus Lagenorhynchus has an anti-tropical distribution and has the largest aggregations along continental shel
Michigan State University - LBS - 144
&quot;Corporate Environmental Crime: Current Research and Connections to Fisheries and Wildlife&quot; In criminology, corporate crime refers to crimes committed either by a corporation or by individuals that may be identified with a corporation or other busine
Michigan State University - LBS - 118
Michigan State University - LBS - 118
Michigan State University - LBS - 171L
`Lab 1: Spectroscopy of Atoms and IonsKaelyn Petras Kristin Magruder LBS171L Section 008 TA: Merideth Lindeman FitzpatrickSeptember 19, 20061Wavelength of Spectroscopy 500 550 590 630 700 750Wavelength of Ocean Optics 510.7 534.3 600.5 64
Michigan State University - LBS - 171L
Petras/Willner1Determining Concentration of Phosphates in Water through Titration Kaelyn Petras Jenny Willner October 12, 2006LBS171L Section 008 TA: Merideth Lindeman FitzpatrickPetras/Willner2Abstract- Titration was used to find the average
Michigan State University - LBS - 171L
Petras/Falk1Creating Soap and Biodiesel Fuel using Vegetable Oil and New Canola Oil Kaelyn Petras Daniel FalkLBS171L Section 008 TA: Merideth Lindeman FitzpatrickDecember 6, 2006Petras/Falk2Abstract: Two different oils were used to create so
Michigan State University - LBS - 171L
Petras1Lab 3: Stoichiometry and Green Chemistry Kaelyn Petras LBS171L Sec 008 TA: Merideth Fitzpatrick October 11th, 2006Petras2 I. II. III. Title: Green Chemistry Purpose: The purpose of this lab was to determine the mass ratio of a mixture of s
University of Texas - CH - 301
CHAPTER 2Chemical Bonds1IntroductionAttractive forces that hold atoms together in compounds are called chemical bonds. The electrons involved in bonding are usually those in the outermost (valence) shell.2IntroductionChemical bonds are cl