37 Pages

P.Lecture - 2.21.08

Course: EE 312, Spring 2008
School: University of Texas
Rating:
 
 
 
 
 

Word Count: 2891

Document Preview

Assignment Announcements 3 D Due next Tuesday by midnight t T d b id i ht Assignment 4 Out next Tuesday Out next Tuesday I'm out of town all next week Professor Krasner will be in next week to continue lectures Professor Krasner will be in next week to continue lectures Topics for today Pointers Strings Why do we need pointers? Power of direct manipulation of memory locations is crucial in many...

Register Now

Unformatted Document Excerpt

Coursehero >> Texas >> University of Texas >> EE 312

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.
Assignment Announcements 3 D Due next Tuesday by midnight t T d b id i ht Assignment 4 Out next Tuesday Out next Tuesday I'm out of town all next week Professor Krasner will be in next week to continue lectures Professor Krasner will be in next week to continue lectures Topics for today Pointers Strings Why do we need pointers? Power of direct manipulation of memory locations is crucial in many embedded and locations is crucial in many embedded and systems software applications Its faster to pass only a reference (pointer) Its faster to pass only a reference (pointer) instead of a whole array or structure to a function Pointers are required to do file IO (next week) Others reasons later Pointer Concepts The pointer type supports indirect addressing The pointer type supports indirect addressing A pointer variable holds a memory address rather than a value What's the difference? Basic unary operations are: & the "address of" operator (We've already seen this. Where?) * the indirection operator or "contents at" an address Pointer variables have to be declared along with the type of data that they point to data that they point to E.g, (p is not an integer, but capable of pointing to an int) int *p; /* a pointer variable p must point to an int */ Mixed type pointer manipulations are not allowed int *p; double q; double *q; p = q; /* not allowed */ Before it's assigned a value, a pointer points to nothing in particular The Address Operator p A pointer can be given a value by assigning it the address of a variable To determine the address of a variable, use the address operator (&) int i, *p; p = &i; /* now p points t i */ &i /* i t to i */ The Indirection Operator p To determine what a pointer points to, use the indirection operator (*) int i, *p; ... p = &i; printf("%d\n", *p); If p points to i, then *p is just another name for i Pointer Implementation Memory p A pointer variable(e.g. p) contains the memory address t i th dd of another variable or location as its value 25 x int p = 0; / set p to NULL / int *p = 0; /*set p to NULL*/ int x; p = &x; /* p is given the address of x */ x 25; x = 25; / or *p = 25; */ /* or p 25; / printf("Value is %d \n", (*p) ); Pointer Assignment g One pointer may be assigned another, provided both have the same type h h int i, *p, *q; p = &i; q = p; After the assignment, both p and q point to I Don't confuse pointer assignment with assignment using Don t confuse pointer assignment with assignment using indirection: int i, j, *p, *q; p = &i; q = &j; i = 1; /* p is pointing to 1 (i), q is pointing to some undefined value (j) */ *q = *p; /* p and q now both point to 1, though different memory locations */ * * /* d b th i t t 1 th h diff t l ti */ What does this do? int number ; int *p1, *p2; p1 = & number ; number = 23; number = 23; p2 = & number ; printf (" *p1 = %d *p2 = %d ", *p1, *p2); Pointers as Arguments g For a function to be able to modify a variable, it must be given a pointer to the variable: be given a pointer to the variable: void swap(int *a, int *b) { int temp; temp = *a; *a = *b; *b = temp; b temp; } ... int x, y; int x y; swap(&x, &y); The arguments of scanf must be pointers to places to The arguments of scanf must be pointers to places to store the input Using const to Protect Arguments g g The const specifier provides a way to protect arguments from change: void f(const int *p) { int j; i j *p = 0; /* illegal */ p = &j; / legal / p = &j; /* legal */ } Pointers as Return Values Functions may return pointer values: i l int *max(int *a, int *b) { if (*a > *b) { ( ){ return a; } else { else { return b; } } ... p p = max(&x, &y); ( , y); Never return a pointer to a local variable l l i bl int *f(void) { int i; ; ... return &i; } The variable i will not exist once f returns, so exist once f returns so the pointer will be invalid Pointers and Arrays y A pointer variable may point to an element of an array an array int a[10], *p; p = &a[0]; p = &a[0]; *p = 5; / p points to the beginning of a / /* p points to the beginning of a */ /* stores 5 into a[0] */ With scanf: With scanf: scanf("%d", &a[i]); Pointer Arithmetic Only addition subtraction and comparison operations are Only addition, subtraction and comparison operations are allowed for pointer variables Remember, a pointer is just a memory location, which is just a number int *p =0, *q =0; int *p 0 *q 0; int x[4] = {25, 37, 77, 99}; p = &x[0]; /* OR just p = x; when x is an array */ q = p; q++; if (p < q) printf ("p points to a lower address\n"); printf ("value is %d", *(q + 2)); /* what value is output? */ A pointer can be used to index through a list/array of elements / char str[ ] = "Test"; char *p ; int i; int i; for( p = &str[0], i=0; *p != '\0'; p++, i++) printf(" The character at position %d is %c\n ", i, *p); When two pointers are subtracted the result is the distance (in array When two pointers are subtracted, the result is the distance (in array elements) between the pointers Only meaningful if the pointers point into the same array Array Names and Pointers y The name of an array can be used as a pointer to the first element in an array fi l i int a[10]; *a = 0 a = 0 / stores 0 in a[0] / /* stores 0 in a[0] */ The second element can be accessed through a+1 *(a+1) = 1 /* stores 1 in a[1] */ ( ) / [ ] / In general, a+i is another way to write &a[i] g g p Moving through a loop: char str[ ] = "Test"; char *p ; int i; for( p = str, i=0; *p != '\0'; p++, i++) printf(" The character at position %d is %c\n ", i, *p); Array Arguments Revisited When an array is used as an argument to a function, the function is given a pointer to the array's first element. int a[N]; [ ] store_zeroes(a, N); This is why a function can modify the elements of an y y array parameter (but not OTHER parameters) void store_zeroes(int a[], int n) { int i; int i; for (i = 0; i < n; i++) a[i] = 0; } T To protect an array argument from change, use const t t tf h t int find_largest(const int a[], int n); An array parameter can be declared as a pointer instead: An array parameter can be declared as a pointer instead: void store_zeroes(int *a, int n); int find_largest(const int *a, int n); Multiple Indirection Variables q A pointer variable contains the memory address of another pointer variable as its value p double **q; double p; double *p; double x = 25.7; p = &x; q = &p; & printf ("%le" ,**q); 25.7 x What's a String? g Basically, a sequence (array) of characters. What do we do with Strings? Input and output them Make a bigger String out of little ones Make a bigger String out of little ones Break big Strings into smaller ones Do comparisons (like in chars) Extremely useful in any application that manipulates text (e.g. translators, word processors, language puzzles, etc.) String Literals String literals are enclosed in double quotes; e.g.: "Put a disk in drive A, then press any key to continue\n" Put a disk in drive A, then press any key to continue\n A string literal may be extended over more than one line by writing \ immediately followed by the end of the line: y g\ y y printf("Put a disk in drive A, then \ press any key to continue\n"); A string literal may be divided into two or more shorter strings; the compiler will join these together into one string: printf("Put a disk in drive A, then " "press any key to continue\n"); " k t ti \ ") How String Literals Are Stored The string literal "abc" is represented by the three characters a, b, and c, followed by a null character (\0): a b c \0 Lik Like any array, a string literal is represented by a pointer t th t i lit l i t db i t to the first character in the string A string literal of length 1 is different from a character constant g g A string literal of length 1 (e.g., "a") is represented by a pointer A character constant (e.g., `a') is represented by an integer value Don't use a character constant when a string literal is required ' h h l l d (or viceversa): printf("\n"); //is legal, because printf expects a string as its first parameter printf('\n'); // \ //is not legal. String Variables A string variable is just a one dimensional array of characters: A string variable is just a onedimensional array of characters: #define STR_LEN 80 char str [STR_LEN+1]; The array should be one character longer than the string it will hold, to leave space for the null character at the end. Leave room for the null character when using stringhandling Leave room for the null character using when string handling functions in the C library. A string variable can be initialized: char date1[8] = "June 14"; A string initializer need not completely fill the array: char date2[9] = "June 14"; char date2[9] "June 14"; The leftover array elements are filled with null characters: If the length of the array is omitted, the compiler will compute it: char date3[ ] = "June 14 "; /* date3 is 9 characters long */ Reading and Writing Strings To read or write a string, use scanf or printf with the %s conversion specification: scanf( %s str); scanf("%s", str); printf( %s , str); printf("%s" str); scanf skips white space, then reads characters into str until it encounters a whitespace character This is a problem if you want more than 1 word No ampersand is needed when using scanf to read into a string variable variable Since a string variable is an array, the name of the variable is already a pointer (to the beginning of the array) Af A faster alternative: Use gets and puts f l i U d functions: i gets(str); gets reads characters into str until it encounters a newline character. puts(str); puts prints str, followed by a newline character. Reading and Writing Strings (cont.) scanf and gets automatically put a null at the end of the input string g printf and puts assume that the output string ends with a null Both scanf and gets assume that the string variable is large enough to contain the input string (including the null at the end) Failing to make the variable long enough will have unpredictable results Failing to make the variable long enough will have unpredictable results To make scanf safer, use the conversion specification %ns, where n specifies the maximum number of characters to be read. d Use fgets instead of gets for greater safety Allows you to specify max length of string to read Allows you to specify max length of string to read Accessing the Characters Because of the close relationship between arrays and pointers, the elements of a string can be accessed by normal array subscripting or pointer reference l b i ti i t f Here is a function that counts the number of spaces in a given string: a given string: int count_spaces(const char s[ ]) { int count, i; count = 0; for (i = 0; s[i] != '\0'; i++) { if (s[i] if (s[i] = = ' ') count++; ) count++; } return count; } Accessing the Characters (cont.) g ( ) The Code from before: int count_spaces(const char s[ ]) { int count, i; count = 0; for (i = 0; s[i] != '\0'; i++) { for (i 0 s[i] ! '\0' i++) { if (s[i] = = ' ') count++; } return count; return count; } Pointer version: int count_spaces(const char *s) { i t t ( t h * ){ int count; count = 0; for (; s != \0 ; s++) { for (; *s != `\0'; s++) { if (*s == ` `) { count++; } } return count; } Using the C String Library C provides some builtin support for strings Since strings are treated as arrays, they are restricted in the same ways as arrays--in particular, strings cannot be copied or compared by array i ti l ti tb i d db name. Why? Attempts to copy or compare two strings using C's builtin operators will fail: char str1[10], str2[10]; str1 = str2; /* illegal */ t 1 t 2 /* ill l */ if (str1 == str2) ... /* will produce the wrong result */ The C library provides a set of functions for performing The C library provides a set of functions for performing operations on strings. These functions reside in <string.h>. The strcpy Function strcpy copies one string into another: char str1[10], str2[10]; char str1[10] str2[10]; strcpy(str1, "abcd"); /* str1 now contains "abcd" */ strcpy(str2, str1); /* str2 now contains "abcd" */ strcpy(str2 str1); /* str2 now contains "abcd" */ strcpy calls can be chained: strcpy(str2, strcpy(str1, "abcde")); ( ( " b ")) /* both str1 and str2 now contain "abcde" */ strcpy has no way to check that the second string will fit into the first one The strcat Function strcat appends the contents of one string to the end of another ("concatenates"): char str[10] = "abc"; strcat(str, "def"); /* str now contains "abcdef" */ strcat has no way to check that the first string y g can accommodate the added characters. The strcmp Function strcmp compares two strings: if (strcmp(str1, str2) < 0) ... strcmp returns a value less than, equal to, or greater than 0, depending on whether str1 is less than, equal to, or greater than str2 greater than str2 strcmp considers str1 to be less than str2 if The first i characters of str1 and str2 match, but the (i+1)st The first i characters of str1 and str2 match, but the (i+1)st character of str1 is less than the (i+1)st character of str2 (for example, "abc" is less than "acc", and "abc" is less than "bcd"), or than "bcd") or All characters of str1 match str2, but str1 is shorter than ( p , ) str2 (for example, "abc" is less than "abcd") The strlen Function strlen returns the length of a string: int i; char str[10]; i = strlen("abc"); /* i is now 3 */ i = strlen(""); /* i is now 0 */ i t l ("") /* i i 0 */ strcpy(str, "abc "); i = strlen(str); / i is now 4 / i = strlen(str); /* i is now 4 */ When given an array of characters as its argument, strlen does not measure the argument strlen does not measure the declared length of the array; instead, it returns the length of the string stored inside the array. the length of the string stored inside the array Escape Characters in Strings T To get certain characters to show up in a string or be part of a i h h i i b f string (for output or other reasons) we must use a special combination of characters Done just like when using printf (" . . . \n") The \ is a control character. \' \" \\ \n \t \r \f \ \b tab carriage return form feed backspace p single quote double quote back slash character back slash character newline, also called line feed Except for the first three, these are non printable output control character sequences Other Useful String Functions Found in <stdlib.h> Converting strings to numbersgiven a string argument, they return the numeric equivalent strtod string to double strtol string to int string to int strtoul string to long int For example char numberString [ ] = "2345"; double x = strtod (numberString); These replace older functions: atof, atoi, atol p , , Converting numbers to strings; use sprintf () sprintf (string, conversionspec, value); sprintf (s, "%d", i); /* stores the converted value of i into s */ String scanf ( ) sscanf( ) can be used to convert a string into its known elements known elements Example: read a line (fgets) & extract a number int value; int value; / variable for the input value / /* variable for the input value */ char line[80]; /* temp variable for input line */ g ( ( ) ) fgets( line, sizeof(line), stdin); sscanf( line, "%d", &value ); You must make sure that the variable formats and types agree String Functions Summary g y all the standard array algorithms for: searching, adding, removing, sorting the char [ ] can be used ddi i i h h [] b d various input and output functions strcpy strcat strcmp strlen number to/from string conversion functions String Examples Make a computer password out of the first letters of a person's first, middle and last names, appended with the person's age Reverse the contents of a string Create a Password Program int main ( ) { int main ( ) { char [ ] firstName = "harold"; char [ ] middleName = "joseph"; char [ ] lastName = hacker ; char [ ] lastName "hacker"; char [6] password = ""; int age = 19; /* assume this is the age of the user */ char [3] stringAge = ""; /* to hold age as a string */ h [3] t i A "" /* t h ld t i */ /* extract&concatonate the first letter of first, middle,last names*/ strcat (password, firstName [0]); strcat (password, middleName [0]); ( d iddl N [0]) strcat (password, lastName [0]); /* convert & append age to the initials to create a password */ sprintf (stringAge, "%d", age); /*convert age to a string */ / / strcat (password, stringAge); printf ("Your password is %s ", password); return 0; } String Reverser /* create a copy of a string in reverse order */ int i =0; char ch; char [80] phrase; /* the initial string*/ char [80] reversed; /* the reversed string*/ gets (phrase); i = strlen (phrase); reversed = ""; while (i >= 0) { ch = phrase [i]; strcat (reversed, ch); i = i 1; } reversed [strlen (phrase)] = `\0'; printf ("the reversed string is %s\n", reversed);
Textbooks related to the document above:
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 - EE - 312
Weekly ScheduleM 9:00 Nikhil Nikhil 10:00 Shadi, Nikhil Shadi, Nikhil, Sunil 11:00 Shadi, Nikhil, Sunil Shadi, Nikhil, Sunil 12:00 Shadi, Sunil Shadi 13:00 Mahesh Mahesh 14:00 Mahesh Shadi, Mahesh 15:00 Shadi, Mahesh Shadi, Mahesh 16:00 Shadi, Mahes
University of Texas - EE - 312
Announcements Assignment 2 Offi Office Hours today d Topics for today Type conversions and casting Typedef and sizeof arrays 1D arrays 1DUsual Arithmetic Conversions in Expressions Promotions, e.g: A + B Promotions e g: A + BIn mixed type
University of Texas - EE - 312
Announcements Assignment 2 due today! Exam 1 next Thursday 50 minute exam (9:30 10:20) Topics for today Functions Scope of variables1Functions in a Nutshell A named collection of statements Somewhat like mathematical functions: y = f(
University of Texas - EE - 312
Announcements Assignment 2 Topics for today i f d Partially filled arrays Array algorithms Array algorithms Multidimensional arraysPartially Filled Array Arrays cannot grow after they have been allocated p ( ) y You can allocate more space
University of Texas - EE - 312
Announcements Blackboard Discussion Blackboard Discussion Avoid emailing your TAs with questions about assignments/lectures Course Communication Groups Opt out by today 5pm Optout by today 5pm For today: Finish floating point numbers Format
University of Texas - EE - 312
Announcements Assignment 3 out today Assignment 3 and 4 logisitics Exam 1 Thursday 55 minute exam (9:30 10:25) Program Development Measurement g p SLOC, person hours, logic defects Topics for today Topics for today Scope of variables Ex
University of Texas - EE - 312
Announcements Assignment 3 Exam 1 Graded Back in recitations on Friday Statistics on Thursday (hopefully) Read Chapters 11,12, 13 and 22 Topics for today Matrices Random numbers Strings (time permitting)Review: 2D Arrays Used for table
University of Texas - EE - 312
Announcements Assignment 2 posted today Assignment 2 posted today Quizzes C Coding Style C C di S l For today: Finish looping control statements (Chap. 6) More on types (Chap. 7)For loop The for statement has the formfor ( expression1 ; exp
University of Texas - EE - 312
E E 312 Notes 2.5Arrays Matrix Int variable [r][c] Int my2Darray [3,3] o That means evaluate 3 for 3 Use for statement and nested loops Allows you to make a change in the rows and columns Scan ( %f, &amp;energy[][]); 2d arrays Not easier for us to do
University of Texas - EE - 312
E E 312 Notes February 7, 2008--A named collection of statements o Somewhat like mathematical functions o Arguments are not required Does not need to return a value Functions are like &quot;mini-programs&quot; called by name Top line: declarations Libra
University of Texas - EE - 312
E E 312 Notes February 12, 2008Know Source Lines of Codes Know how many hours you spent on your assignment o Need to do this for Assignment #2 Global Variables o Also called external variables o Are declared outside of your main function o Should
University of Texas - EE - 312
Announcements Assignment 1 due tonight Assignment 1 due tonight Blackboard assignment manager More on Blackboard discussion board More on Blackboard discussion board getchar() For today: Introduction to algorithm design using flowcharts or ps
University of Texas - EE - 312
EE 312 Notes--------Malloc = sets a memory block for the size of bytes you need o Used as a pointer o Ex: p = malloc(sizeof(int); o Will return null if cannot find size o Make sure to check for null Calloc= allocates space for an ar
University of Texas - EE - 312
EE312 Lecture 2 Announcements Topics for today will answer the questions: Survey Results What is the C programming language ? What is C syntax ? What is C s nta ? Assignment statement Numerical expressions Numerical expressions Number stora
University of Texas - EE - 312
Weekly ScheduleM 9:00 Nikhil Nikhil 10:00 Shadi, Nikhil Shadi, Nikhil, Sunil 11:00 Shadi, Nikhil, Sunil Shadi, Nikhil, Sunil 12:00 Shadi, Sunil Shadi 13:00 Mahesh Mahesh 14:00 Mahesh Shadi, Mahesh 15:00 Shadi, Mahesh Shadi, Mahesh 16:00 Shadi, Mahes
University of Texas - EE - 312
16 Frequency Table Type Instruction count 0 3 1 1 2 3 3 2 4 4 5 0 6 3 7 0 8 0 9 0 5 Frequency Table Type Instruction count 0 0 1 1 2 1 3 0 4 2 5 0 6 0 7 1 8 0 9 0 835 Frequency Table Type Instruction count 0 822 1 1 2 1 3 1 4 2 5 3 6 2 7 1 8 1 9 1 15
University of Texas - EE - 312
EE312 Introduction to Programming I d i P iSpring 2008 Christine Julien Christine Julien Assistant Professor c.julien@mail.utexas.edu Office: ACES 5.140 Offi ACES 5 140 Office Hours: TTh: 1112:30Introductions The Teaching Team Instructor Chris
University of Texas - PHY - 303K
homework 05 FONTENOT, BRIAN Due: Feb 18 2008, 4:00 am Question 1, chap 5, sect 5. part 1 of 2 10 points A child holds a sled on a frictionless, snowcovered hill, inclined at an angle of 26 . F87 N 01Question 4, chap 5, sect 5. part 2 of 2 10 p
University of Texas - EE - 312
E E 312 Notes 1.27For Loops For (expression 1; expression 2; expression 3) statement Ex: for (i=10; I &gt; 0; i-) o Printf(&quot;T Minus %d and counting\n&quot;, i) - I is at 10, check if I is greater than zero, then decrement I and go back and check to see if
University of Texas - PHY - 303K
oldmidterm 01 FONTENOT, BRIAN Due: Feb 14 2008, 3:00 pm Question 1, chap 1, sect 5. part 1 of 1 10 points A newly discovered Jupiter-like planet has an average radius 10.6 times that of the Earth and a mass 313 times that of the Earth. Calculate th
University of Texas - PHY - 303K
midterm 01 FONTENOT, BRIAN Due: Feb 13 2008, 11:00 pm1Mechanics - Basic Physical ConceptsMath: Circle: 2 r, r2 ; Sphere: 4 r2 , (4/3) r3 b2 Quadratic Eq.: a x2 + b x + c = 0, x = -b 2 a-4 a cCartesian and polar coordinates: y x = r cos ,
University of Texas - EE - 312
E E 312 Discussion Notes How to Read arrays: /* Int couter, coutner2 For (coutner=0, array[coutner] &lt; nextinput; coutner+); For (counter 2= arraysize; counter2&gt;count; coutner2 -) { Array[count2]=array[count 2-1]; Arrayszie+ Scanf(&quot;); */
University of Texas - PHY - 303K
homework 04 FONTENOT, BRIAN Due: Feb 11 2008, 4:00 am Question 1, chap 4, sect 5. part 1 of 3 10 points An athlete swings a 6.72 kg ball horizontally on the end of a rope. The ball moves in a circle of radius 0.995 m at an angular speed of 0.787 re
University of Texas - PHY - 303K
homework 04 FONTENOT, BRIAN Due: Feb 11 2008, 4:00 am Question 1, chap 4, sect 5. part 1 of 3 10 points An athlete swings a 6.72 kg ball horizontally on the end of a rope. The ball moves in a circle of radius 0.995 m at an angular speed of 0.787 re
University of Texas - PHY - 303K
homework 05 FONTENOT, BRIAN Due: Feb 18 2008, 4:00 am Question 1, chap 5, sect 5. part 1 of 2 10 points A child holds a sled on a frictionless, snowcovered hill, inclined at an angle of 26 . F87 N1= T = W sin = (87 N) sin 26 = 38.1383 N .Qu
University of Texas - PHY - 303K
homework 02 FONTENOT, BRIAN Due: Jan 28 2008, 4:00 am Question 1, chap 2, sect 5. part 1 of 3 10 points In deep space (no gravity), the bolt (arrow) of a crossbow accelerates at 129 m/s2 and attains a speed of 125 m/s when it leaves the bow. For ho
University of Texas - PHY - 303K
homework 03 FONTENOT, BRIAN Due: Feb 4 2008, 4:00 am Question 1, chap 3, sect 4. part 1 of 3 10 points Consider the two vectors M = (a, b) = a^+ i b ^ and N = (c, d) = c^ + d ^, where a = 4, i b = 4, c = 3, and d = -3. a and c represent the x-dis
University of Texas - PHY - 303K
homework 03 FONTENOT, BRIAN Due: Feb 4 2008, 4:00 am and Question 1, chap 3, sect 4. part 1 of 3 10 points Consider the two vectors M = (a, b) = a^+ i b ^ and N = (c, d) = c^ + d ^, where a = 4, i b = 4, c = 3, and d = -3. a and c represent the x
University of Texas - PHY - 303K
homework 07 FONTENOT, BRIAN Due: Mar 3 2008, 4:00 am Question 1, chap 8, sect 1. part 1 of 3 10 points A 3 kg block collides with a massless spring of spring constant 94 N/m attached to a wall. The speed of the block was observed to be 1.3 m/s at t
University of Texas - EE - 312
E E 312 NotesArithmetic Conversions With Floats o o Float + Double = Double Double + Int = DoubleNot With Floats o Int + int = int o Int &lt; unsigned int &lt; long int o Never combine unsigned ints and regular ints in expressions The value on the righ
University of Texas - EE - 312
EE 312 Notes Recursion using the stack Parameters are stored in the stack Stacks are LIFO Pushing = Adding an Item Popping = Removing an Item System Support Maintains an activation record Activation Record (Stack Frame) looks like the following o Inc
University of Texas - EE - 312
EE 312 NotesExam 2: Chapters 9.6 11-13; 15-17; 22. File Inclusion Want to include own file. Use #include &quot;filename&quot; Looks in local directories first Only One source file must contain a definition of main Create header files to include just your hea
University of Texas - PHY - 303K
homework 06 FONTENOT, BRIAN Due: Feb 25 2008, 4:00 am Question 1, chap 7, sect 1. part 1 of 3 10 points Assume you are on a planet similar to Earth where the acceleration of gravity g 10 m/s2 . A plane 50 m in length is inclined at an angle of 16.
University of Texas - PHY - 303K
midterm 01 FONTENOT, BRIAN Due: Feb 13 2008, 11:00 pm1Mechanics - Basic Physical ConceptsMath: Circle: 2 r, r2 ; Sphere: 4 r2 , (4/3) r3 b2 Quadratic Eq.: a x2 + b x + c = 0, x = -b 2 a-4 a cCartesian and polar coordinates: y x = r cos ,
University of Texas - EE - 312
EE312 C Coding Standards Spring 2008Writing code that is easy for others (or you later) to read is an important part of programming. Style entails a program's readability and logic structuring. Style is almost as important as correctness in program
University of Texas - EE - 312
E E 312 Discussion 1.18.2008 Most general computer Consist of a microprocessor o o o Intel x86 Takes instructions Computes a resultProgrammer o o o o o Job is to write instructions to build jobs Use programming language Our language is C Something
University of Texas - EE - 312
Dicussion Session EE 312 1/25/08Printf (&quot; %4d&quot;, 86); Printf(&quot;%06d&quot;, 86); Printf(&quot;%4d&quot;, 10405); shows*/ Printf(&quot;%12.5e, 30.253); Control Statements: If(i&gt;2) J = 100; Else J =-100; Can set Multiple Parameters= = = =|_|_86| |000086| |10405| /* On
University of Texas - EE - 312
C PROGRAMMING A Modern ApproachAnswers to Even-Numbered ExercisesSusan A. Cole K. N. KingW W Norton &amp; Company New York LondonCopyright 1996 W. W. Norton &amp; Company, Inc. All rights reserved. W. W. Norton &amp; Company, Inc. 500 Fifth Avenue, Ne
University of Texas - EE - 312
EE 312 Programming Project #3 Flow Chart Brian Fontenot (BLF339) 15670 F: 11-12
University of Texas - EE - 312
EE 312 Programming Project #3 Flow Chart Brian Fontenot (BLF339) 15670 F: 11-12Start programdeclare variablesdeclare arrayIntialize arrayIntialize variablesprompt user informationscan for user inputread user inputsort out prime num
University of Texas - EE - 312
10 299 492 495 399 492 495 399 283 279 689 078 100 000 000 000 456 789 234 453 125 175 183 256 012 100 000 212 415 521 721 532 439 543 631 339 923 029 873 674 027 023 610 621 632 643 654 665 676 687698 609 201 805 229 429 100 100 456 789 234 453 12
University of Texas - EE - 312
EE312 Introduction to Programming I d i P iSpring 2008 Christine Julien Christine Julien Assistant Professor c.julien@mail.utexas.edu Office: ACES 5.140 Offi ACES 5 140 Office Hours: TTh: 1112:30Introductions The Teaching Team Instructor Chris
University of Texas - EE - 312
EE312 Lecture 2 Announcements Topics for today will answer the questions: Survey Results What is the C programming language ? What is C syntax ? What is C s nta ? Assignment statement Numerical expressions Numerical expressions Number stora
University of Texas - EE - 312
Micro architecture, logic circuits, and device technology -1st layer hardware vs. software Machine assembly language instruction set machine code High level programming language - c programming Not finished Need the designModels, design, and abstr
University of Texas - EE - 312
Notes 1.17 The History of C Was called NB o BCPL Orignated from the UNIX System By Denins Ritchie in Bell Labs Between 1969 and 1973 Became popular in the 1980s Original C o Called K&amp;R C By Kernighan and Ritchie o ANSI C ANSI Standard X3.159-1989
University of Texas - EE - 312
Read Chapter 3, 7, 22 Know Chapter 2 for Quiz on FridayNotes 1.22 Floats Float single precision Double double precision Long double extreme precision Must contain decimal point or exponent By default stored as double-precision numbers F or f, L
University of Texas - EE - 312
EE 312 Notes January 24, 2008Selection o Deciding among alternative executive paths Boolean values stored in variables Tested by program Using If and Else Statements Nested and Cascaded If statements Using Switch Statements Conditional Operators
University of Texas - EE - 312
EE 312 Notes January 24, 2008Sequence Follow Sequence 1, 2, 3 Condition is True Do until false Iteration False loop back to beginSelection Condition is true go to end Condition is not true, then do functionSelection o Deciding among a
University of Texas - EE - 312
E E 312 Notes Argc = number of pointers Char *argv[] = each value that is pass into function Int main ( int argc, char *argv[]) Command line &gt;myprog.c one two three Argc = 4 Argv[0] = &quot;my prog.c&quot; Argv[1]=&quot;one&quot; Argv[2] = &quot;two&quot; Argv[3] = &quot;three&quot; File i
University of Texas - BIO - 311C
Chapter 7Membrane Structure and FunctionLecture OutlineOverview: Life at the Edge The plasma membrane separates the living cell from its nonliving surroundings. This thin barrier, 8 nm thick, controls traffic into and out of the cell. Like all
University of Texas - BIO - 311C
Chapter 13Meiosis and Sexual Life CyclesLecture OutlineOverview: Hereditary Similarity and Variation Living organisms are distinguished by their ability to reproduce their own kind. Offspring resemble their parents more than they do less closely
University of Texas - BIO - 311C
Chapter 14 Mendel and the Gene IdeaLecture OutlineOverview: Drawing from the Deck of Genes Every day we observe heritable variations (such as brown, green, or blue eyes) among individuals in a population. These traits are transmitted from parents t
University of Texas - BIO - 311C
Chapter 16Lecture OutlineThe Molecular Basis of InheritanceOverview: Life's Operating Instructions In April 1953, James Watson and Francis Crick shook the scientific world with an elegant double-helical model for the structure of deoxyribonuclei
University of Texas - BIO - 311C
Chapter 15The Chromosomal Basis of InheritanceLecture OutlineOverview: Locating Genes on Chromosomes Today we know that genes-Gregor Mendel's &quot;hereditary factors&quot;-are located on chromosomes. A century ago, the relationship of genes and chromosom
University of Texas - BIO - 311C
Chapter 17From Gene to ProteinLecture OutlineOverview: The Flow of Genetic Information The information content of DNA is in the form of specific sequences of nucleotides along the DNA strands. The DNA inherited by an organism leads to specific t
University of Texas - BIO - 311C
Chapter 18The Genetics of Viruses and BacteriaLecture OutlineOverview: Microbial Model Systems Viruses and bacteria are the simplest biological systems- microbial models in which scientists find life's fundamental molecular mechanisms in their m
University of Texas - BIO - 311C
Chapter 20DNA Technology and GenomicsLecture OutlineOverview: Understanding and Manipulating Genomes One of the great achievements of modern science has been the sequencing of the human genome, which was largely completed by 2003. Progress began
University of Texas - BIO - 311C
Chapter 19Eukaryotic GenomesLecture OutlineOverview: How Eukaryotic Genomes Work and Evolve Two features of eukaryotic genomes present a major information-processing challenge. First, the typical multicellular eukaryotic genome is much larger th
University of Texas - BIO - 311C
Chapter 21The Genetic Basis of DevelopmentLecture OutlineOverview: From Single Cell to Multicellular Organism The application of genetic analysis and DNA technology to the study of development has brought about a revolution in our understanding
University of Texas - BIO - 311C
Chapter 22 Descent with Modification: Darwinian View of LifeLecture OutlineOverview: Darwin Introduces a Revolutionary Theory On November 24, 1859, Charles Darwin published On the Origin of Species by Means of Natural Selection. Darwin's book dre
University of Texas - BIO - 311C
Chapter 23Lecture OutlineThe Evolution of PopulationsOverview: The Smallest Unit of Evolution One common misconception about evolution is that organisms evolve, in a Darwinian sense, during their lifetimes. Natural selection does act on individ