Characters & Strings in C
|
|
- Rachel Booker
- 5 years ago
- Views:
Transcription
1 Recently, we saw this: Characters & Strings in C % cat charweird.c #include <stdio.h> main () { /* main */ char c; c = 75; printf("c = %d\n", c); printf("c = %c\n", c); if (c) { printf("c is true\n"); } /* if c */ else { printf("c is false\n"); } /* if c...else */ } /* main */ % cc -o charweird charweird.c % charweird c = 75 c = K c is true We understood how the variable c could be treated as an integer, by accepting that the type char really just refers to the number of bytes that the data takes up (in this case, 1 byte). We also understood how the variable c could be treated as an Boolean, because Boolean values are implemented in C by using integers, with 0 denoting False and nonzero denoting True. But how does setting c to the integer value 75 give us a result of K? 1
2 Numeric Representation of Non-numeric Values In Programming Project #3, we encoded (represented) filing status with an integer; specifically: 1: single status 2: married filing jointly If we wanted to add other filing statuses, we could have had, for example: 3: married filing separately 4: head of household 5: widow/er Likewise in Programming Project #4, some people encoded the letter grades like so: 1: A 2: B 3: C 4: D 5: F And others encoded them like so: 4: A 3: B 2: C 1: D 0: F So, we can encode qualitative (non-numeric) variables with quantitative (numeric) values, using arbitrary but distinct numeric values to encode a set of qualities. 2
3 How Characters Are Represented What s the most important set of non-numeric values in computing? It s the one that allows the computer to communicate with us in a way that makes sense to actual real live human beings: natural language. The most efficient way for computers to communicate in a natural language is by writing. Writing is based on characters. Characters are non-numeric. So, we want a way to encode characters numerically. Here s a code you might have used to play secret code games when you were a kid: A 1, B 2, C 3, D 4,..., Z 26 Now that you ve grown up and taken CS1313, you realize that the numbers that you choose can be arbitrary, as long as they re distinct, so you could just as easily choose: A 65, B 66, C 67, D 68,..., Z 90 This is a perfectly reasonable encoding, if the only characters that you care about are upper case letters. What about lower case? Well, you could add, for example: a 97, b 98, c 99, d 100,..., z 122 Are these the only characters that you need? 3
4 Digits & Punctuation Another kind of very important character is a digit. Here s a possible encoding of the decimal digits: 0 48, 1 49, 2 50, 3 51,..., 9 57 Notice that there s an important distinction between the character to be represented, which happens to be a digit, and the numeric encoding, whose value doesn t have to have anything to do with the value of the digit being encoded. But wait, there s more! In addition to the upper case letters, the lower case letters and the digits, we also need to encode special characters such as punctuation. This is starting to get pretty complicated, so maybe it d help to have a chart. 4
5 The American Standard Code for Information Interchange (ASCII) 1 Code Char Kbd Name Code Char Kbd Name 0 NUL Null 16 DLE Ctrl-P Data Line Escape 1 SOH Ctrl-A Start Of Heading 17 DC1 Ctrl-Q Device Control 1 2 STX Ctrl-B Start Of Text 18 DC2 Ctrl-R Device Control 2 3 ETX Ctrl-C End Of Text 19 DC3 Ctrl-S Device Control 3 4 EOT Ctrl-D End Of Transmission 20 DC4 Ctrl-T Device Control 4 5 ENQ Ctrl-E Enquiry 21 NAK Ctrl-U Negative Ack 6 ACK Ctrl-F Acknowledge 22 SYN Ctrl-V Synchronous File 7 BEL Ctrl-G Ring Bell 23 ETB Ctrl-W End Transmission Block 8 BS Ctrl-H Backspace 24 CAN Ctrl-X Cancel 9 HT Ctrl-I Horizontal Tab 25 EM Ctrl-Y End of Medium 10 LF Ctrl-J Line Feed 26 SUB Ctrl-Z Substitute 11 VT Ctrl-K Vertical Tab 27 ESC Ctrl-Shift-K Escape 12 FF Ctrl-L Form Feed 28 FS Ctrl-Shift-L File Separator 13 CR Ctrl-M Carriage Return 29 GS Ctrl-Shift-M Group Separator 14 SO Ctrl-N Shift Out 30 RS Ctrl-Shift-N Record Separator 15 SI Ctrl-O Shift In 31 US Ctrl-Shift-O Unit Separator Code Char Name Code Char Name Code Char Name 32 space at 96 accent grave 33! exclamation point 65 A 97 a 34 " double quote 66 B 98 b 35 # pound 67 C 99 c 36 $ dollar sign 68 D 100 d 37 % percent 69 E 101 e 38 & ampersand 70 F 102 f 39 single quote 71 G 103 g 40 ( open parenthesis 72 H 104 h 41 ) close parenthesis 73 I 105 i 42 * asterisk 74 J 106 j 43 + plus 75 K 107 k 44, comma 76 L 108 l 45 - hyphen 77 M 109 m 46. period 78 N 110 n 47 / slash 79 O 111 o P 112 p Q 113 q R 114 r S 115 s T 116 t U 117 u V 118 v W 119 w X 120 x Y 121 y 58 : colon 90 Z 122 z 59 ; semicolon 91 [ open square bracket 123 { open curly brace 60 < less than 92 \ backslash 124 vertical bar 61 = equal 93 ] close square bracket 125 } close curly brace 62 > greater than 94 ^ caret 126 ~ tilde 63? question mark 95 underscore 127 DEL delete 5
6 ASCII 1 Confirmation Example % cat ascii.c #include <stdio.h> main () { /* main */ int c; for (c = 32; c <= 63; c++) printf("%3d: %c %3d: %c %3d %c\n", c, c, c+32, c+32, c+64, c+64); } /* main */ % cc -o ascii ascii.c % ascii 32: 96 33:! 65: A 97 a 34: " 66: B 98 b 35: # 67: C 99 c 36: $ 68: D 100 d 37: % 69: E 101 e 38: & 70: F 102 f 39: 71: G 103 g 40: ( 72: H 104 h 41: ) 73: I 105 i 42: * 74: J 106 j 43: + 75: K 107 k 44:, 76: L 108 l 45: - 77: M 109 m 46:. 78: N 110 n 47: / 79: O 111 o 48: 0 80: P 112 p 49: 1 81: Q 113 q 50: 2 82: R 114 r 51: 3 83: S 115 s 52: 4 84: T 116 t 53: 5 85: U 117 u 54: 6 86: V 118 v 55: 7 87: W 119 w 56: 8 88: X 120 x 57: 9 89: Y 121 y 58: : 90: Z 122 z 59: ; 91: [ 123 { 60: < 92: \ : = 93: ] 125 } 62: > 94: ^ 126 ~ 63:? 95: Arthur Gill, Machine and Assembly Language Programming of the PDP-11, 2nd ed, Prentice- Hall, New Jersey, 1983, pp
7 Character Variables in C In C, we can declare variables of type char: char c; We can also assign character values to character variables, by enclosing them in single quotes: c = q ; We can output character values from character variables, using the %c placeholder: printf("my favorite character is: Here s an example: % cat charscalar.c #include <stdio.h> main () { /* main */ char mychar, yourchar; %c\n", c); mychar = q ; printf("what is your favorite character? "); scanf("%c", &yourchar); printf("your favorite character is: %c\n", yourchar); printf("my favorite character is: %c\n", mychar); } /* main */ % cc -o charscalar charscalar.c % charscalar What is your favorite character? z Your favorite character is: z My favorite character is: q The problem here is how much of a pain it d be to have to write words and sentences this way. 7
8 Character Arrays in C In C, you can have an array of type char, just as you can have arrays of numeric types: char myname[12]; We can fill this array with characters and be able to print them out: myname[0] = H ; myname[1] = e ; myname[2] = n ; myname[3] = r ; myname[4] = y ; myname[5] = ; myname[6] = N ; myname[7] = e ; myname[8] = e ; myname[9] = m ; myname[10] = a ; myname[11] = n ; We can put this to use like so: % cat chararray.c #include <stdio.h> main () { /* main */ char myname[12]; int c; myname[0] = H ; myname[1] = e ; myname[2] = n ; myname[3] = r ; myname[4] = y ; myname[5] = ; myname[6] = N ; myname[7] = e ; myname[8] = e ; myname[9] = m ; myname[10] = a ; myname[11] = n ; printf("my name is: "); for (c = 0; c < 12; c++) printf("%c", myname[c]); printf("\n"); } /* main */ % cc -o chararray chararray.c % chararray My name is: Henry Neeman This is an improvement, but it s still not an efficient way to store a sequence of characters in memory. 8
9 Character Strings in C In C A character string is a sequence of characters that is interpreted as a single item of data. In C, a character string is an array of characters terminated by a null character (ASCII value 0); i.e., the last character in the array is a null. % cat chararraystr.c #include <stdio.h> main () { /* main */ char myname[13]; char mynamestr1[13] = "Henry Neeman"; char mynamestr2[13]; int c; myname[0] = H ; myname[1] = e ; myname[2] = n ; myname[3] = r ; myname[4] = y ; myname[5] = ; myname[6] = N ; myname[7] = e ; myname[8] = e ; myname[9] = m ; myname[10] = a ; myname[11] = n ; myname[12] = \0 ; strcpy(mynamestr2, "Henry Neeman"); printf("my name is: "); for (c = 0; c < 12; c++) printf("%c", myname[c]); printf("\n"); printf("my name string is: %s\n", myname); printf("my name string is: %s\n", mynamestr1); printf("my name string is: %s\n", mynamestr2); } /* main */ % cc -o chararraystr chararraystr.c % chararraystr My name is: Henry Neeman My name string is: Henry Neeman My name string is: Henry Neeman My name string is: Henry Neeman In C, a character scalar is delimited by single quotes and its placeholder is %c, while a character string is delimited by double quotes, and its placeholder is %s. 9
10 Character Strings in Fortran 90 Just as in C, in Fortran 90 we have character strings, but they are declared with an additional attribute: CHARACTER (LEN=12) :: myname % cat chararraystrf.f90 PROGRAM chararraystrf IMPLICIT NONE CHARACTER,DIMENSION(1:12) :: myname CHARACTER (LEN=12) :: mynamestr1 = "Henry Neeman" CHARACTER (LEN=12) :: mynamestr2 INTEGER :: c myname(1) = "H" myname(2) = "e" myname(3) = "n" myname(4) = "r" myname(5) = "y" myname(6) = " " myname(7) = "N" myname(8) = "e" myname(9) = "e" myname(10) = "m" myname(11) = "a" myname(12) = "n" mynamestr2 = "Henry Neeman" PRINT *, "My name is: ", (myname(c), c = 1, 12) PRINT *, "My name is: ", mynamestr1 PRINT *, "My name is: ", mynamestr2 END PROGRAM chararraystrf % f90 -o chararraystrf chararraystrf.f90 % chararraystrf My name is: Henry Neeman My name is: Henry Neeman My name is: Henry Neeman In Fortran 90, you can delimit both character scalars and character strings with either single quotes or double quotes. The only constraint is that the delimiters must be a matched pair; that is, both delimiters must be single quotes, or both delimiters must be double quotes. 10
11 Character String Expressions in Fortran 90 Fortran 90 has some pretty powerful intrinsic string operators and functions: 1. Substrings: string(start:end) 2. Concatenation: str1 // str2 3. Creation: REPEAT(str,count) 4. Modification (a) Trailing blank removal: TRIM(str) (b) Left justify: ADJUSTL(str) removes leading blanks, adds an equal number of trailing blanks (c) Right justify: ADJUSTL(str) removes trailing blanks, adds an equal number of leading blanks 5. Length (a) Total length: LEN(str) (b) Length before trailing blanks: LEN TRIM(str) 6. Encoding/Decoding (a) Encode character to ASCII: IACHAR(chr) (b) Encode character to native code: ICHAR(chr) (c) Encode character from ASCII: ACHAR(integ) (d) Encode character from native code: CHAR(integ) 7. Comparison (a) Greater than: LGT(str1,str2) (b) Greater than or equal to: LGE(str1,str2) (c) Less than: LLT(str1,str2) (d) Less than or equal to: LLE(str1,str2) You can find a complete listing of string manipulators in Programming in Fortran 90/95, 6th ed, pages
12 F90 Character String Expression Example % cat strintrinsics.f90 PROGRAM strintrinsics IMPLICIT NONE CHARACTER (LEN=12) myname CHARACTER (LEN=3) mydegree CHARACTER (LEN=10) mynose myname = "Henry Neeman" mydegree = "PhD" mynose = "bulbous" PRINT *, myname(7:9) PRINT *, myname // ", " // mydegree PRINT *, REPEAT(mydegree,3) PRINT *, " " // TRIM(mynose) // " " PRINT *, " " // ADJUSTL(mynose) // " " PRINT *, " " // ADJUSTR(mynose) // " " PRINT *, LEN(mynose), LEN_TRIM(mynose) PRINT *, IACHAR("A") =, IACHAR("A") PRINT *, ICHAR("A") =, ICHAR("A") PRINT *, ACHAR(65) =, ACHAR(65) PRINT *, CHAR(65) =, CHAR(65) PRINT *, myname, " LGT ", mydegree, " = ", & & LGT(myname,mydegree) PRINT *, myname, " LGE ", mydegree, " = ", & & LGE(myname,mydegree) PRINT *, myname, " LGE ", myname, " = ", & & LGE(myname,myname) PRINT *, myname, " LLT ", mydegree, " = ", & & LLT(myname,mydegree) PRINT *, myname, " LLE ", mydegree, " = ", & & LLE(myname,mydegree) PRINT *, myname, " LLE ", myname, " = ", & & LLE(myname,myname) END PROGRAM strintrinsics % f90 -o strintrinsics strintrinsics.f90 % strintrinsics Nee Henry Neeman, PhD PhDPhDPhD bulbous bulbous bulbous 10 7 IACHAR("A") = 65 ICHAR("A") = 65 ACHAR(65) = A CHAR(65) = A Henry Neeman LGT PhD = F Henry Neeman LGE PhD = F Henry Neeman LGE Henry Neeman = Henry Neeman LLT PhD = T Henry Neeman LLE PhD = T Henry Neeman LLE Henry Neeman = 12 T T
13 C Character String Expression Example % cat strfuncs.c #include <stdio.h> main () { /* main */ char myname[13] = "Henry Neeman"; char mydegree[4] = "PhD"; char mynose[11] = "bulbous"; char tempstr[100]; tempstr[0] = \0 ; strcat(tempstr, myname); strcat(tempstr, ", "); strcat(tempstr, mydegree); printf("%s\n", tempstr); tempstr[0] = \0 ; strcat(tempstr, mydegree); strcat(tempstr, mydegree); strcat(tempstr, mydegree); printf("%s\n", tempstr); printf("strlen(%s) = %d\n", myname, strlen(myname)); printf(" %c == %d\n", A, A ); printf("strcmp(%s,%s) == %d\n", myname, mydegree, strcmp(myname, mydegree)); printf("strcmp(%s,%s) == %d\n", myname, myname, strcmp(myname, myname)); printf("strcmp(%s,%s) == %d\n", myname, mynose, strcmp(myname, mynose)); printf("strcmp(%s,%s) == %d\n", mynose, mydegree, strcmp(mynose, mydegree)); } /* main */ % cc -o strfuncs strfuncs.c % strfuncs Henry Neeman, PhD PhDPhDPhD strlen(henry Neeman) = 12 A == 65 strcmp(henry Neeman,PhD) == -1 strcmp(henry Neeman,Henry Neeman) == 0 strcmp(henry Neeman,bulbous) == -1 strcmp(bulbous,phd) == 1 13
14 Arrays of Character Strings in C Just as you can have an array of type int, or an array of type float, or an array of type char, you can also have an array of char strings. Of course, an individual string is an array of type char. So an array of strings is an array of arrays of type char; that is, it s a 2D array of type char. % cat stringarray.c #include <stdio.h> #define NUM_NAMES 5 #define MAX_NAME_LENGTH 64 main () { /* main */ char name[num_names][max_name_length] = { "Nelson Mandela", "Jerry Yang", "Madeleine Albright", "Jennifer Lopez", "Albert Einstein" }; int s; printf("here are your names:\n"); for (s = 0; s < NUM_NAMES; s++) printf("%2d: %s\n", s, name[s]); } /* main */ % cc -o stringarray stringarray.c % stringarray Here are your names: 0: Nelson Mandela 1: Jerry Yang 2: Madeleine Albright 3: Jennifer Lopez 4: Albert Einstein 14
1. Character/String Data, Expressions & Intrinsic Functions. Numeric Representation of Non-numeric Values. (CHARACTER Data Type), Part 1
Character/String Data, Expressions Intrinsic Functions (CHARACTER Data Type), Part 1 1. Character/String Data, Expressions Intrinsic Functions (CHARACTER Data Type), Part 1 2. Numeric Representation of
More informationCharacters Lesson Outline
Outline 1. Outline 2. Numeric Encoding of Non-numeric Data #1 3. Numeric Encoding of Non-numeric Data #2 4. Representing Characters 5. How Characters Are Represented #1 6. How Characters Are Represented
More informationASCII Code - The extended ASCII table
ASCII Code - The extended ASCII table ASCII, stands for American Standard Code for Information Interchange. It's a 7-bit character code where every single bit represents a unique character. On this webpage
More information2a. Codes and number systems (continued) How to get the binary representation of an integer: special case of application of the inverse Horner scheme
2a. Codes and number systems (continued) How to get the binary representation of an integer: special case of application of the inverse Horner scheme repeated (integer) division by two. Example: What is
More information1.1. INTRODUCTION 1.2. NUMBER SYSTEMS
Chapter 1. 1.1. INTRODUCTION Digital computers have brought about the information age that we live in today. Computers are important tools because they can locate and process enormous amounts of information
More informationFD-011WU. 2D Barcode Reader User Guide V1.6CC
FD-011WU 2D Barcode Reader User Guide V1.6CC Table of Contents 1 Getting Started... 1 1.1 Factory Defaults... 1 2 Communication Interfaces...2 2.1 TTL-232 Interface... 2 2.2 Baud Rate... 3 2.3 Data Bit
More informationNumber Systems II MA1S1. Tristan McLoughlin. November 30, 2013
Number Systems II MA1S1 Tristan McLoughlin November 30, 2013 http://en.wikipedia.org/wiki/binary numeral system http://accu.org/index.php/articles/18 http://www.binaryconvert.com http://en.wikipedia.org/wiki/ascii
More informationOOstaExcel.ir. J. Abbasi Syooki. HTML Number. Device Control 1 (oft. XON) Device Control 3 (oft. Negative Acknowledgement
OOstaExcel.ir J. Abbasi Syooki HTML Name HTML Number دهدهی ا کتال هگزاد سیمال باینری نشانه )کاراکتر( توضیح Null char Start of Heading Start of Text End of Text End of Transmission Enquiry Acknowledgment
More informationChapter 3. Information Representation
Chapter 3 Information Representation Instruction Set Architecture APPLICATION LEVEL HIGH-ORDER LANGUAGE LEVEL ASSEMBLY LEVEL OPERATING SYSTEM LEVEL INSTRUCTION SET ARCHITECTURE LEVEL 3 MICROCODE LEVEL
More informationDATA REPRESENTATION. Data Types. Complements. Fixed Point Representations. Floating Point Representations. Other Binary Codes. Error Detection Codes
1 DATA REPRESENTATION Data Types Complements Fixed Point Representations Floating Point Representations Other Binary Codes Error Detection Codes 2 Data Types DATA REPRESENTATION Information that a Computer
More informationMK D Imager Barcode Scanner Configuration Guide
MK-5500 2D Imager Barcode Scanner Configuration Guide V1.4 Table of Contents 1 Getting Started... 3 1.1 About This Guide... 3 1.2 Barcode Scanning... 3 1.3 Factory Defaults... 3 2 Communication Interfaces...
More informationEXPERIMENT 8: Introduction to Universal Serial Asynchronous Receive Transmit (USART)
EXPERIMENT 8: Introduction to Universal Serial Asynchronous Receive Transmit (USART) Objective: Introduction To understand and apply USART command for sending and receiving data Universal Serial Asynchronous
More informationEXPERIMENT 7: Introduction to Universal Serial Asynchronous Receive Transmit (USART)
EXPERIMENT 7: Introduction to Universal Serial Asynchronous Receive Transmit (USART) Objective: To understand and apply USART command for sending and receiving data Introduction Universal Serial Asynchronous
More informationFundamentals of Programming (C)
Borrowed from lecturer notes by Omid Jafarinezhad Fundamentals of Programming (C) Group 8 Lecturer: Vahid Khodabakhshi Lecture Number Systems Department of Computer Engineering Outline Numeral Systems
More informationReview. Single Pixel Filters. Spatial Filters. Image Processing Applications. Thresholding Posterize Histogram Equalization Negative Sepia Grayscale
Review Single Pixel Filters Thresholding Posterize Histogram Equalization Negative Sepia Grayscale Spatial Filters Smooth Blur Low Pass Filter Sharpen High Pass Filter Erosion Dilation Image Processing
More informationThe following are the data types used in the C programming language:
Data Types in C The following are the data types used in the C programming language: Type Definition Size in memory void This particular type is used only in function declaration. boolean It stores false
More informationData Representa5on. CSC 2400: Computer Systems. What kinds of data do we need to represent?
CSC 2400: Computer Systems Data Representa5on What kinds of data do we need to represent? - Numbers signed, unsigned, integers, floating point, complex, rational, irrational, - Text characters, strings,
More informationCMSC 313 Lecture 03 Multiple-byte data big-endian vs little-endian sign extension Multiplication and division Floating point formats Character Codes
Multiple-byte data CMSC 313 Lecture 03 big-endian vs little-endian sign extension Multiplication and division Floating point formats Character Codes UMBC, CMSC313, Richard Chang 4-5 Chapter
More informationUnit 3, Lesson 2 Data Types, Arithmetic,Variables, Input, Constants, & Library Functions. Mr. Dave Clausen La Cañada High School
Unit 3, Lesson 2 Data Types, Arithmetic,Variables, Input, Constants, & Library Functions Mr. Dave Clausen La Cañada High School Vocabulary Variable- A variable holds data that can change while the program
More informationData Representation and Binary Arithmetic. Lecture 2
Data Representation and Binary Arithmetic Lecture 2 Computer Data Data is stored as binary; 0 s and 1 s Because two-state ( 0 & 1 ) logic elements can be manufactured easily Bit: binary digit (smallest
More informationData Representa5on. CSC 2400: Computer Systems. What kinds of data do we need to represent?
CSC 2400: Computer Systems Data Representa5on What kinds of data do we need to represent? - Numbers signed, unsigned, integers, floating point, complex, rational, irrational, - Text characters, strings,
More informationChapter 8. Characters and Strings
Chapter 8 Characters and s OJECTIVES After you have read and studied this chapter, you should be able to Declare and manipulate data of the char data type. Write string processing programs using and uffer
More information2D Barcode Reader User Guide V 1.2.1
2D Barcode Reader User Guide V 1.2.1 Table of Contents 1 Getting Started... 3 1.1 About This Guide... 3 1.2 Barcode Scanning... 3 1.3 Factory Defaults... 3 1.4 Firmware Version Number... 3 2 Communication
More informationS-Series Sensor ASCII Protocol v8.1.0
S-Series Sensor v8.1.0 Legend: ADR Node/Slave Address TIME STAT Status Byte ERR CTRL Control Byte SP # POS Position DATA TARG Target CHAR VEL Velocity OFF SN CODE PAR # Serial Number Security Code Parameter
More informationBits and Bytes. Data Representation. A binary digit or bit has a value of either 0 or 1; these are the values we can store in hardware devices.
Bits and Bytes 1 A binary digit or bit has a value of either 0 or 1; these are the values we can store in hardware devices. A byte is a sequence of 8 bits. A byte is also the fundamental unit of storage
More informationCMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 02, FALL 2012
CMSC 33 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 2, FALL 22 TOPICS TODAY Bits of Memory Data formats for negative numbers Modulo arithmetic & two s complement Floating point formats
More informationFundamentals of Programming
Fundamentals of Programming Lecture 2 Number Systems & Arithmetic Lecturer : Ebrahim Jahandar Some Parts borrowed from slides by IETC1011-Yourk University Common Number Systems System Base Symbols Used
More informationFundamental Data Types
Fundamental Data Types Lecture 4 Sections 2.7-2.10 Robb T. Koether Hampden-Sydney College Mon, Sep 3, 2018 Robb T. Koether (Hampden-Sydney College) Fundamental Data Types Mon, Sep 3, 2018 1 / 25 1 Integers
More informationCS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON
CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON Prof. Gurindar Sohi TAs: Pradip Vallathol and Junaid Khalid Midterm Examination 1 In Class (50 minutes) Friday, September
More informationDo not start the test until instructed to do so!
Instructions: Print your name in the space provided below. This examination is closed book and closed notes, aside from the permitted one-page formula sheet. No calculators or other electronic devices
More informationCS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON
CS/ECE 252: INTRODUCTION TO COMPUTER ENGINEERING UNIVERSITY OF WISCONSIN MADISON Prof. Gurindar Sohi TAs: Junaid Khalid and Pradip Vallathol Midterm Examination 1 In Class (50 minutes) Friday, September
More informationBD-6500BT Bluetooth 2D Barcode Scanner Configuration Guide
BD-6500BT Bluetooth 2D Barcode Scanner Configuration Guide V 2.1 Table of Contents 1 Getting Started. 3 1.1 About This Guide.. 3 1.2 Barcode Scanning.. 3 1.3 Factory Defaults.. 3 1.4 Pairing Cradle 4 1.5
More informationCMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 02, SPRING 2013
CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 02, SPRING 2013 TOPICS TODAY Bits of Memory Data formats for negative numbers Modulo arithmetic & two s complement Floating point
More informationNumber System (Different Ways To Say How Many) Fall 2016
Number System (Different Ways To Say How Many) Fall 2016 Introduction to Information and Communication Technologies CSD 102 Email: mehwish.fatima@ciitlahore.edu.pk Website: https://sites.google.com/a/ciitlahore.edu.pk/ict/
More informationCS341 *** TURN OFF ALL CELLPHONES *** Practice NAME
CS341 *** TURN OFF ALL CELLPHONES *** Practice Final Exam B. Wilson NAME OPEN BOOK / OPEN NOTES: I GIVE PARTIAL CREDIT! SHOW ALL WORK! 1. Processor Architecture (20 points) a. In a Harvard architecture
More informationNumber Representations
Simple Arithmetic [Arithm Notes] Number representations Signed numbers Sign-magnitude, ones and twos complement Arithmetic Addition, subtraction, negation, overflow MIPS instructions Logic operations MIPS
More informationThis is great when speed is important and relatively few words are necessary, but Max would be a terrible language for writing a text editor.
Dealing With ASCII ASCII, of course, is the numeric representation of letters used in most computers. In ASCII, there is a number for each character in a message. Max does not use ACSII very much. In the
More informationDo not start the test until instructed to do so!
Instructions: Print your name in the space provided below. This examination is closed book and closed notes, aside from the permitted one-page formula sheet. No calculators or other electronic devices
More informationChapter 2 Bits, Data Types, and Operations
Chapter Bits, Data Types, and Operations How do we represent data in a computer? At the lowest level, a computer is an electronic machine. works by controlling the flow of electrons Easy to recognize two
More informationBinary Numbers. The Basics. Base 10 Number. What is a Number? = Binary Number Example. Binary Number Example
The Basics Binary Numbers Part Bit of This and a Bit of That What is a Number? Base Number We use the Hindu-Arabic Number System positional grouping system each position represents a power of Binary numbers
More informationIntroduction to Decision Structures. Boolean & If Statements. Different Types of Decisions. Boolean Logic. Relational Operators
Boolean & If Statements Introduction to Decision Structures Chapter 4 Fall 2015, CSUS Chapter 4.1 Introduction to Decision Structures Different Types of Decisions A decision structure allows a program
More informationCharacter Strings Lesson Outline
Outline 1. Outline 2. char Arrays #1 3. char Arrays #2 4. Character Array Example #1 5. Character Array Example #2 6. Character Strings 7. Character String Terminator 8. Character String Assignment Example
More informationMounting Dimensions / Viewing 2 Mounting Options 3. Wiring Configuration 4. Quick Set up Procedure 5. Changing Intensity 6.
Section Mounting Dimensions / Viewing 2 Mounting Options 3 Section 2 Wiring Configuration 4 Section 3 Quick Set up Procedure 5 Section 4 Changing Intensity 6 Section 5 Option Summary 7 Section 6 Option
More informationEE 109 Unit 3. Analog vs. Digital. Analog vs. Digital. Binary Representation Systems ANALOG VS. DIGITAL
3. 3. EE 9 Unit 3 Binary Representation Systems ANALOG VS. DIGITAL 3.3 3. Analog vs. Digital The analog world is based on continuous events. Observations can take on any (real) value. The digital world
More informationChapter 2 Bits, Data Types, and Operations
Chapter 2 Bits, Data Types, and Operations How do we represent data in a computer? At the lowest level, a computer is an electronic machine. works by controlling the flow of electrons Easy to recognize
More informationIf your CNC machine memory is full, the PocketDNC gives you more storage, enabling you to store and reload proven programs at a later date.
Page 1 of 54 Introduction...3 Important! PocketDNC Licence File...3 What s in the Box...4 Setting up Windows Mobile (Win7 Win8 Win10)...5 www.microsoft.com/en-gb/download/details.aspx?id=3182connect Without
More informationASSIGNMENT 5 TIPS AND TRICKS
ASSIGNMENT 5 TIPS AND TRICKS linear-feedback shift registers Java implementation a simple encryption scheme http://princeton.edu/~cos26 Last updated on /26/7 : PM Goals OOP: implement a data type; write
More informationChapter 2 Bits, Data Types, and Operations
Chapter 2 Bits, Data Types, and Operations Original slides from Gregory Byrd, North Carolina State University Modified slides by Chris Wilcox, Colorado State University How do we represent data in a computer?!
More informationExercises Software Development I. 03 Data Representation. Data types, range of values, internal format, literals. October 22nd, 2014
Exercises Software Development I 03 Data Representation Data types, range of values, ernal format, literals October 22nd, 2014 Software Development I Wer term 2013/2014 Priv.-Doz. Dipl.-Ing. Dr. Andreas
More informationn NOPn Unary no operation trap U aaa NOP Nonunary no operation trap i
Instruction set Instruction Mnemonic Instruction Addressing Status Specifier Mode Bits 0000 0000 STOP Stop execution U 0000 0001 RET Return from CALL U 0000 0010 RETTR Return from trap U 0000 0011 MOVSPA
More informationCMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 02, FALL 2012
CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 02, FALL 2012 ANNOUNCEMENTS TA Office Hours (ITE 334): Genaro Hernandez, Jr. Mon 10am 12noon Roshan Ghumare Wed 10am 12noon Prof.
More informationNumbers and Computers. Debdeep Mukhopadhyay Assistant Professor Dept of Computer Sc and Engg IIT Madras
Numbers and Computers Debdeep Mukhopadhyay Assistant Professor Dept of Computer Sc and Engg IIT Madras 1 Think of a number between 1 and 15 8 9 10 11 12 13 14 15 4 5 6 7 12 13 14 15 2 3 6 7 10 11 14 15
More informationExperiment 3. TITLE Optional: Write here the Title of your program.model SMALL This directive defines the memory model used in the program.
Experiment 3 Introduction: In this experiment the students are exposed to the structure of an assembly language program and the definition of data variables and constants. Objectives: Assembly language
More informationSerial I/O. 4: Serial I/O. CET360 Microprocessor Engineering. J. Sumey
4: Serial I/O CET360 Microprocessor Engineering J. Sumey Introduction serial, i.e. bit-at-a-time, interfacing techniques are useful when parallel interfacing limitations become problematic distance limitations
More informationPlainDSP M2M Communication Experimental Details This document describes the machine-to-machine (M2M) communication experiments using PlainDSP.
1 PlainDSP M2M Communication Experimental Details This document describes the machine-to-machine (M2M) communication experiments using PlainDSP. Introduction The PlainDSP kit can be used to recognize frequency
More informationVariables and data types
Programming with Python Module 1 Variables and data types Theoretical part Contents 1 Module overview 4 2 Writing computer programs 4 2.1 Computer programs consist of data and instructions......... 4 2.2
More information2D Hand-held Barcode Scanner User Guide
2D Hand-held Barcode Scanner User Guide 2 / 66 Version History Version Description Date V1.0 Initial release. 2016-11-10 V1.01 Add Data Matrix and PDF417 2017-04-25 3 / 66 Content Chapter 1 Getting Started...
More informationDo not start the test until instructed to do so!
Instructions: Print your name in the space provided below. This examination is closed book and closed notes, aside from the permitted one-page formula sheet. No calculators or other electronic devices
More information5/17/2009. Digitizing Discrete Information. Ordering Symbols. Analog vs. Digital
Chapter 8: Bits and the "Why" of Bytes: Representing Information Digitally Digitizing Discrete Information Fluency with Information Technology Third Edition by Lawrence Snyder Copyright 2008 Pearson Education,
More informationEE 109 Unit 2. Analog vs. Digital. Analog vs. Digital. Binary Representation Systems ANALOG VS. DIGITAL
EE 9 Unit Binary Representation Systems ANALOG VS. DIGITAL Analog vs. Digital The analog world is based on continuous events. Observations can take on any (real) value. The digital world is based on discrete
More informationOberon Data Types. Matteo Corti. December 5, 2001
Oberon Data Types Matteo Corti corti@inf.ethz.ch December 5, 2001 1 Introduction This document is aimed at students without any previous programming experience. We briefly describe some data types of the
More informationUnit 3. Analog vs. Digital. Analog vs. Digital ANALOG VS. DIGITAL. Binary Representation
3.1 3.2 Unit 3 Binary Representation ANALOG VS. DIGITAL 3.3 3.4 Analog vs. Digital The analog world is based on continuous events. Observations can take on (real) any value. The digital world is based
More informationAPPENDIX B. ASSEMBLER DIRECTIVE SUMMARY
APPENDIX B. ASSEMBLER DIRECTIVE SUMMARY Assembler directives are summarized alphabetically in this the contents of directive fields. The following terms are used 10 describe NOTATION Term Expression Numerical
More information+ Inheritance. n Superclass (base class) higher in the hierarchy. n Subclass (child class) lower in the hierarchy
+ Word Clouds + Inheritance n Superclass (base class) higher in the hierarchy n Subclass (child class) lower in the hierarchy n A subclass is derived from from a superclass n Subclasses inherit the fields
More information3.1. Unit 3. Binary Representation
3.1 Unit 3 Binary Representation ANALOG VS. DIGITAL 3.2 3.3 Analog vs. Digital The analog world is based on continuous events. Observations can take on (real) any value. The digital world is based on discrete
More informationLecture (09) x86 programming 8
Lecture (09) x86 programming 8 By: Dr. Ahmed ElShafee 1 Basic Input Output System BIOS BIOS refers to a set of procedures or functions that enable the programmer have access to the hardware of the computer.
More informationChapter 2 Number System
Chapter 2 Number System Embedded Systems with ARM Cortext-M Updated: Tuesday, January 16, 2018 What you should know.. Before coming to this class Decimal Binary Octal Hex 0 0000 00 0x0 1 0001 01 0x1 2
More informationChapter 2 Bits, Data Types, and Operations
Chapter 2 Bits, Data Types, and Operations Original slides from Gregory Byrd, North Carolina State University Modified by Chris Wilcox, S. Rajopadhye Colorado State University How do we represent data
More informationMidterm Exam, Fall 2015 Date: October 29th, 2015
Full Name: Midterm Exam, Fall 2015 Date: October 29th, 2015 Instructions: This midterm exam takes 70 minutes. Read through all the problems and complete the easy ones first. This exam is OPEN BOOK. You
More informationEE 109 Unit 2. Binary Representation Systems
EE 09 Unit 2 Binary Representation Systems ANALOG VS. DIGITAL 2 3 Analog vs. Digital The analog world is based on continuous events. Observations can take on (real) any value. The digital world is based
More informationSimple Data Types in C. Alan L. Cox
Simple Data Types in C Alan L. Cox alc@rice.edu Objectives Be able to explain to others what a data type is Be able to use basic data types in C programs Be able to see the inaccuracies and limitations
More informationPureScan - ML1. Configuration Guide. Wireless Linear Imager Wireless Laser scanner - 1 -
PureScan - ML1 Wireless Linear Imager Wireless Laser scanner Configuration Guide - 1 - Table of Contents Chapter 1 System Information 1.1 About this manual 3 1.2 How to set up the parameter 3 Chapter 2
More informationIPDA014-2D. Embedded 2D Barcode Scan Engine. User Guide
IPDA014-2D Embedded 2D Barcode Scan Engine User Guide 1 Table Of Contents Chapter 1 Getting Started...8 Introduction...8 About This Guide...8 Barcode Scanning...9 Barcode Programming...9 Factory Defaults...9
More informationNumber Systems for Computers. Outline of Introduction. Binary, Octal and Hexadecimal numbers. Issues for Binary Representation of Numbers
Outline of Introduction Administrivia What is computer architecture? What do computers do? Representing high level things in binary Data objects: integers, decimals, characters, etc. Memory locations (We
More informationLecture 10 Arrays (2) and Strings. UniMAP SEM II - 11/12 DKT121 1
Lecture 10 Arrays (2) and Strings UniMAP SEM II - 11/12 DKT121 1 Outline 8.1 Passing Arrays to Function 8.2 Displaying Array in a Function 8.3 How Arrays are passed in a function call 8.4 Introduction
More informationSPEECH RECOGNITION COMMON COMMANDS
SPEECH RECOGNITION COMMON COMMANDS FREQUENTLY USED COMMANDS The table below shows some of the most commonly used commands in Windows Speech Recognition. The words in italics indicate that many different
More informationThe Binary Number System
The Binary Number System Robert B. Heckendorn University of Idaho August 24, 2017 Numbers are said to be represented by a place-value system, where the value of a symbol depends on where it is... its place.
More informationPositional Number System
Positional Number System A number is represented by a string of digits where each digit position has an associated weight. The weight is based on the radix of the number system. Some common radices: Decimal.
More informationFeatures of C. Portable Procedural / Modular Structured Language Statically typed Middle level language
1 History C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was originally first implemented on the DEC
More informationCPS 104 Computer Organization and Programming Lecture-2 : Data representations,
CPS 104 Computer Organization and Programming Lecture-2 : Data representations, Sep. 1, 1999 Dietolf Ramm http://www.cs.duke.edu/~dr/cps104.html CPS104 Lec2.1 GK&DR Fall 1999 Data Representation Computers
More informationplc numbers Encoded values; BCD and ASCII Error detection; parity, gray code and checksums
plc numbers - 3. 3. NUMBERS AND DATA Topics: Number bases; binary, octal,, hexa Binary calculations; s compliments, addition, subtraction and Boolean operations Encoded values; BCD and ASCII Error detection;
More informationCSE-1520R Test #1. The exam is closed book, closed notes, and no aids such as calculators, cellphones, etc.
9 February 2011 CSE-1520R Test #1 [7F] w/ answers p. 1 of 8 CSE-1520R Test #1 Sur / Last Name: Given / First Name: Student ID: Instructor: Parke Godfrey Exam Duration: 45 minutes Term: Winter 2011 The
More informationCSE-1520R Test #1. The exam is closed book, closed notes, and no aids such as calculators, cellphones, etc.
9 February 2011 CSE-1520R Test #1 [B4] p. 1 of 8 CSE-1520R Test #1 Sur / Last Name: Given / First Name: Student ID: Instructor: Parke Godfrey Exam Duration: 45 minutes Term: Winter 2011 The exam is closed
More informationPD1100 STAND-ALONE PROGRAMMING & USER S GUIDE. use the freedom
PD1100 STAND-ALONE ALPHANUMERIC POLE DISPLAY PROGRAMMING & USER S GUIDE use the freedom Forward The information contained in this user s guide is subject to change without notice. This Programming and
More informationCSC 8400: Computer Systems. Represen3ng and Manipula3ng Informa3on. Background: Number Systems
CSC 8400: Computer Systems Represen3ng and Manipula3ng Informa3on Background: Number Systems 1 Analog vs. Digital System q Analog Signals - Value varies con1nuously q Digital Signals - Value limited to
More informationChapter 2 Bits, Data Types, and Operations
Chapter 2 Bits, Data Types, and Operations Computer is a binary digital system. Digital system: finite number of symbols Binary (base two) system: has two states: 0 and 1 Basic unit of information is the
More informationConnecting UniOP to Datalogic Barcode Readers
Connecting UniOP to Datalogic Barcode Readers This Technical Note contains the information needed to connect UniOP to Datalogic Barcode Scanners. Contents 1. Introduction...1 2. Designer setup...1 2.1
More informationCS 159 Credit Exam. What advice do you have for students who have previously programmed in another language like JAVA or C++?
CS 159 Credit Exam An increasing number of students entering the First Year Engineering program at Purdue University are bringing with them previous programming experience and a many of these students
More informationTable of Contents Sleep Settings How to Configure the Scanner. 7 Chapter 2 System Setup
Table of Contents Chapter 1 System Information 1.1 Setup Scanner with PC 1.2 Setup Scanner with Mobile Device 1.3 Configure ios On-Screen Keyboard 1.4 Memory Mode 3 4 4 5 1.5 Sleep Settings 6 1.6 How to
More informationTELELINK I. A Warner Communications CompanyCI
TELELINK I A Warner Communications CompanyCI Every effort has been made to ensure that this manual accurately documents this product of the ATARI Computer Division However, because of the ongoing improvement
More informationUser s Manual. Xi3000 Scanner. Table of Contents
Xi3000 Scanner User s Manual Table of Contents Restore Default Settings... 1 Exit Setup without Changes... 1 Configure Through RS232... 1 List Setting... 1 Buzzer Settings... 2 Reading Redundancy Setting...
More information.. Cal Poly CPE 101: Fundamentals of Computer Science I Alexander Dekhtyar..
.. Cal Poly CPE 101: Fundamentals of Computer Science I Alexander Dekhtyar.. A Simple Program. simple.c: Basics of C /* CPE 101 Fall 2008 */ /* Alex Dekhtyar */ /* A simple program */ /* This is a comment!
More informationFA269 - DIGITAL MEDIA AND CULTURE
FA269 - DIGITAL MEDIA AND CULTURE ST. LAWRENCE UNIVERSITY a. hauber http://blogs.stlawu.edu/digitalmedia DIGITAL TECHNICAL PRIMER INCLUDED HERE ARE THE FOLLOWING TOPICS A. WHAT IS A COMPUTER? B. THE DIFFERENCE
More informationUniversal Asynchronous Receiver Transmitter Communication
Universal Asynchronous Receiver Transmitter Communication 13 October 2011 Synchronous Serial Standard SPI I 2 C Asynchronous Serial Standard UART Asynchronous Resynchronization Asynchronous Data Transmission
More information6.096 Introduction to C++ January (IAP) 2009
MIT OpenCourseWare http://ocw.mit.edu 6.096 Introduction to C++ January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. Welcome to 6.096 Lecture
More informationFundamentals of Programming
Fundamentals of Programming Lecture 4 Input & Output Lecturer : Ebrahim Jahandar Borrowed from lecturer notes by Omid Jafarinezhad Outline printf scanf putchar getchar getch getche Input and Output in
More informationPassword Management Guidelines for Cisco UCS Passwords
Guidelines for Cisco UCS Passwords, page 1 Guidelines for Cisco UCS Usernames, page 3 Configuring the Maximum Number of Password Changes for a Change Interval, page 4 Configuring a No Change Interval for
More informationCSE 30 Winter 2014 Final Exam
Signature Login: cs30x Name Student ID By filling in the above and signing my name, I confirm I will complete this exam with the utmost integrity and in accordance with the Policy on Integrity of Scholarship.
More informationSECURITY PROTECTION OF SOFTWARE PROGRAMS BY INFORMATION SHARING AND AUTHENTICATION TECHNIQUES USING INVISIBLE ASCII CONTROL CODES*
SECURITY PROTECTION OF SOFTWARE PROGRAMS BY INFORMATION SHARING AND AUTHENTICATION TECHNIQUES USING INVISIBLE ASCII CONTROL CODES* 1, 3 I-Shi Lee( 李義溪 ), 1, 2, Wen-Hsiang Tsai ( 蔡文祥 ) 1 Department of Computer
More informationENCM 339 Fall 2017 Lecture Section 01 Lab 3 for the Week of October 2
page 1 of 11 ENCM 339 Fall 2017 Lecture Section 01 Lab 3 for the Week of October 2 Steve Norman Department of Electrical & Computer Engineering University of Calgary September 2017 Lab instructions and
More information