CSc 352: Basic C Programming

Size: px
Start display at page:

Download "CSc 352: Basic C Programming"

Transcription

1 CSc 352: Basic C Programming

2 What s new relative to Java? Some syntactic differences a lot of the basic syntax is similar assignment, conditionals, loops, etc. The biggest differences are conceptual procedural rather than object-oriented no notion of classes and inheritance hierarchies much closer to the machine debugging sometimes requires thorough understanding of what s going on at the machine level explicit dynamic memory management (malloc, free) pointers 2

3 What s new relative to Java? No Garbage Collection No array boundary protection You have much more control This means you can write faster programs This also means code can be hard to debug and security vulnerabilities are much more likely C is generally compiled to machine code (java programs require java machine to be installed) 3

4 The program development process Simple programs (single source file) source code compiler gcc executable code C program created with an editor ASCII text human-readable machine code created using compiler binary file not human-readable

5 The program development process More complex programs (many source files) source files compiler object files file1.c gcc -c file1.o file2.c gcc -c file2.o linker executable code file n.c gcc -c file n.o

6 gcc The c compiler we ll be using on lectura in this class is gcc. gcc can create an executable file from a text file containing C code (called a source file) The source code file should be named <file name>.c The.c indicates that the file contains C source code gcc has MANY possible options, but in this class there are a couple we will almost always use: 6

7 gcc -Wall tells gcc to print out most warning messages your code must show no warnings when compiled with this option -o <file name> This tells gcc to name the executable file <file name> generally you will name the executable the same name as the source code file without the.c 7

8 gcc For example, if you have a C source code file called project2.c, then typing gcc Wall o project2 project2.c will hopefully create an executable file called project2 If the -o option is omitted, gcc will name the executable file a.out 8

9 A simple program 9

10 A simple program a simple C program that prints out hello followed by a return Points to note: execution begins at main(): every program must have one printf() is a standard C library routine the comic forgot the \n 10

11 A simple program invoking the C compiler compiler warning executable file produced by compiler executing the program 11

12 Gcc options: -Wall gcc Wall generates warnings on questionable constructs if no return type is specified for a function, it defaults to int need to supply prototype for printf 12

13 Fixing the compiler warnings specifies prototype for printf() specifies return type explicitly 13

14 Summary execution starts at main() every program should have one the return type for a function defaults to int the return type should be specified explicitly: good style You need to supply prototypes for functions imported from elsewhere (e.g., standard libraries). specified using #include 14

15 A simple program revisited 15

16 Gcc options: -Wall gcc Wall generates warnings on questionable constructs if no return type is specified for a function, it defaults to int need to supply prototype for printf 16

17 Fixing the compiler warnings How do we know what file to include? 17

18 The man command (review) The man command displays documentation for commands (and more). Here is an abridged example the "man page" for cat: % man cat CAT(1) CAT(1) User Commands NAME cat - concatenate files and print on the standard output SYNOPSIS cat [OPTION]... [FILE]... DESCRIPTION Concatenate FILE(s), or standard input, to standard output. -A, --show-all equivalent to vet... With no FILE, or when FILE is -, read standard input.

19 Manual sections The UNIX "manual" is divided into these sections: (from man man) 1 User commands 2 System calls (functions provided by the kernel) 3 Library calls (functions within program libraries) 4 Special files (usually found in /dev) 5 File formats and conventions eg /etc/passwd 6 Games 7 Miscellaneous (including macro packages and conventions), e.g. man(7), groff(7) 8 System administration commands (usually only for root) 9 Kernel routines [Non standard] Recall that man cat showed CAT(1). That "(1)" tells us that cat is a user command. man malloc shows MALLOC(3). That "(3)" tells us that malloc is a library function.

20 man scanf Header file 20

21 man printf Where is the header file? 21

22 man printf bottom There is both a user command and library call called printf 22

23 man 3 printf 23

24 Simple declarations and statements two uninitialized global variables, x and y, of type int a variable, z, of type int, that is local to the function main; initialized to 12 print format specifier: %d = print an integer in decimal format simple arithmetic expressions and assignment statements 24

25 Quick aside: Formatted Output: printf() takes a variable no. of arguments: printf( fmtstr, arg 1, arg 2,, arg n ) text: Ch. 3 Sec. 3.1 fmtstr is a string that can contain conversion specifiers the no. of conversion specifiers should be equal to n regular (non-%) characters in fmtstr written out unchanged each conversion specifier is introduced by % this is followed by additional (optional) characters specifying how wide the output is to be, precision, padding, etc. the conversion specifier indicates how the specified value is to be interpreted: d = decimal integer, e.g.: printf( value = %d\n, n); x = hex integer, e.g.: printf( hex value of %d is %x\n, x, x); f = floating point number, e.g.: printf( area = %f\n, A); 25

26 Simple conditionals, while loops if statement while statement error message: sent to stderr return value communicates normal/abnormal execution 26

27 For loops 27

28 Function calls, recursion function call recursion 28

29 Function calls (cont d) What happens when this printf() is called? the arguments are evaluated (as in all C function calls) factorial(6) evaluated when factorial() returns, the printf is executed: printf(, 720) This causes the string factorial(6) = 720 to be printed out 29

30 Formatted Input: scanf() takes a variable no. of arguments: scanf( fmtstr, arg 1, arg 2,, arg n ) text: Ch. 3 Sec. 3.2 fmtstr is a string that can contain conversion specifiers the no. of conversion specifiers should be equal to n arg i are locations where values that are read in should be placed each conversion specifier is introduced by % similar to conversions for printf execution behavior: uses format string to read in as many input values from stdin as it can return value indicates the no. of values it was able to read return value of EOF (-1) indicates no further input ( end of file ). 30

31 scanf() Specifying where to put an input value: in general we need to provide a pointer to the location where the value should be placed for a scalar variable X, this is typically written as &X a pointer is needed because the calling function gives the called function a copy of the argument 31

32 scanf() Examples: scanf( %d, &n) : reads a decimal value into a variable n scanf( %d %d %d, &x, &y, &z) : reads three decimal values separated by spaces and put them into variables x, y, z respectively suppose the input contains the values 12, 3, 71, 95, 101 separated by spaces. Then: x 12; y 3; z 71; return value = 3 suppose the input contains the values 19, 23. Then: x 19; y 23; z is unassigned; return value = 2 32

33 Exercise Which of these are correct? int x; printf( %d\n, x); int x, y; printf( %d, x, y); int x, y, z; printf( %d %d %d, x, y, z); int x, y; printf(%d, %d, x, y); int f(int n); printf( f(%d)= %d\n, n, f(n)); int x, y; printf( %d %d\n, x); 33

34 Exercise Which of these are correct? int x; printf( %d\n, x); int x, y; printf( %d, x, y); int x, y, z; printf( %d %d %d, x, y, z); int x, y; printf(%d, %d, x, y); int f(int n); printf( f(%d)= %d\n, n, f(n)); int x, y; printf( %d %d\n, x); X wrong no. of arguments X format specifier needs to be a string... X wrong no. of arguments 34

35 Exercise Which of these are correct? int x; scanf( %d\n, x); int x, y; scanf( %d %d, &x, &y); int x, y, z; scanf( %d %d %d, &x, &y, &z); int x, y; scanf(%d, %d, &x, &y); int f(int n); scanf( f(%d)= %d\n, &n, &f(n)); int x, y; scanf( %d %d\n, &x); 35

36 Exercise Which of these are correct? int x; scanf( %d\n, x); int x, y; scanf( %d %d, &x, &y); int x, y, z; scanf( %d %d %d, &x, &y, &z); int x, y; scanf(%d, %d, &x, &y); int f(int n); scanf( f(%d)= %d\n, &n, &f(n)); int x, y; scanf( %d %d\n, &x); X need &x X format specifier needs to be a string... X &f(n) doesn t make sense X wrong no. of arguments 36

37 Quick comment on the exercises You should understand the mistakes, and learn to spot them as well, but every issue that was illustrated will either be a compiler error or warning. 37

38 Reading inputs: ^D and end-of-file int main() { while (scanf( %d, &n)!= EOF) {... } } source code the system indicates EOF when there is no more input to read input from file./a.out < infile gcc executable Assuming the input is good, the program will above will terminate after all of the data from the file infile is read. How do you indicate the end of file (EOF) when input comes from the keyboard? 38

39 Reading inputs: ^D and end-of-file typing ctrl-d ends input stream (EOF) keyboard input int main() { while (scanf( %d, &n)!= EOF) {... } } gcc source code the system indicates EOF when there is no more input to read input from file./a.out < infile If the program above is taking input from the keyboard, pressing ctrl-d will send an EOF causing the loop condition to fail, and the program to exit executable 39

40 Reading inputs: ^C, ^D, and end-of-file keyboard input infinite loop int main() { while (scanf( %d, &n) < 2) {... } } gcc source code input from file executable./a.out < infile control-c kills the process 40

41 Assignment: l-values increment x twice? what s going on? 41

42 Assignment: l-values The left-hand-side (destination) of an assignment has to be a location this is referred to as an l-value Consider the expression x the outer ++ operator attempts to increment x++ but x++ is an expression that has no location! error x has a location and a value the ++ operator assigns the value x+1 to the location of x the expression x ++ has the new value of x, but no location (as a side-effect, x gets incremented) 42

43 What can be an l-value? l-values: variables of arithmetic type (int, char, float, etc.) array elements: x[y] also: structs, unions, pointers, etc. (to be discussed later) operations involving pointers (to be discussed later) Not l-values: functions result of an assignment value returned by a function call 43

44 Expressions and Statements A statement is a command to be executed when a program is run printf( hello\n ); x = 5; An expression is something which computes to a value 5 x + y x == 8 44

45 Expressions and Statements (continued) In c, most statements are expression statements which are expressions followed by a semi-colon. The execution of such statements is simply their evaluation, with any side effects Loosely, a side effect is an action that happens while evaluating an expression Examples without side effects (the compiler will tell you that these have no effect. 5; x + y; Examples with side effects (next page) 45

46 Expressions and Statements Expressions with side effects when evaluated scanf( %d, &i) evaluates to the number of variables assigned values side effect: stores value in i x++ x = 8 evaluates to x side effect: stores the value of x + 1 in x evaluates to 8 side effect stores the value 8 in x 46

47 Expressions and Statements So the assignment = in c is really an operator that returns the value to the right and has a side effect of storing that value in the variable to the left This is why x = y = z = 1 is legal in c. (The assignment operator is evaluated from left to right). a = b += c++ - d + --e / -f is legal, well defined, but BAD programming (DON T DO IT) Would you want to evaluate it? There are many legal C expressions that you should not use because they are not clear (many will cause compiler warnings) if in doubt, be less clever. 47

48 Another bad example a = 5; c = (b = a + 2) (a = 1); This is legal but NOT well defined. Sometimes it will evaluate to 6 and sometimes 2. Even on the same machine. There is no reason to ever devise such constructions (except to demonstrate bad behavior, or to compete in the obfuscated C contest --- see 48

49 A Common C Error if (x = 5) {... } I had meant x == 5, but I typed it wrong. But in c, this is still legal. x = 5 stores the value of 5 in x and evaluates to 5 5 is considered true by c (everything not 0 is true), so the if statement ALWAYS executes. Fortunately, the Wall option for gcc will warn about this error. 49

50 Primitive data types: Java vs. C C provides some numeric types not available in Java unsigned The C language provides only a minimum size guarantee for primitive types the actual size may vary across processors and compilers Originally C did not have a boolean type faked it with ints: 0 false; non-0 true hence you will see code of the form: if ( (x = getnum()) ) { } // if value read is nonzero C99 provides some support for booleans 50

51 Primitive numeric types: Java vs. C Java C C size Comments byte short int long unsigned char signed char typically (and at least) 8 bits typically (and at least) 8 bits char typically (and at least) 8 bits signedness is implementation dependent unsigned short int signed short int typically (and at least) 16 bits same as unsigned short unsigned int 16 or 32 bits the natural size for the machine signed int same as unsigned int unsigned long int at least 32 bits, often 64 signed long int == unsigned long Keywords in gray may be omitted 51

52 Signed vs. unsigned values Essential idea: signed : the highest bit of the value is interpreted as the sign bit (0 = positive; 1 = negative) unsigned : the highest bit not interpreted as sign bit For an n-bit value: signed: value ranges from 2 n-1 to 2 n-1 1 unsigned: value ranges from 0 to 2 n 1 Right-shift operator ( >> ) may behave differently unsigned values: 0s shifted in on the left (signed) negative values: bits shifted in is implementation dependent 52

53 Booleans Originally, C didn t have a separate boolean type truth values were ints: 0 = false; non-0 = true still commonly used in programming C99 provides the type _Bool _Bool is actually an (unsigned) integer type, but can only be assigned values 0 or 1, e.g.: _Bool flag; flag = 5; /* flag is assigned the value 1 */ C99 also provides boolean macros in stdbool.h: #include <stdbool.h> bool flag; /* same as _Bool flag */ flag = true; 53

54 Arithmetic operators: Java vs. C Most of the common operators in C are as in Java e.g.: +, ++, +=, -, -=, *, /, %, >>, <<, &&,, C doesn t have operators relating to objects: new, instanceof C doesn t have >>> (and >>>=) use >> on unsigned type instead 54

55 prototypes recall: 55

56 warnings when compiled gcc Wall generates warnings on questionable constructs if no return type is specified for a function, it defaults to int need to supply prototype for printf 56

57 Fixing the compiler warnings What does this really do? 57

58 prototypes What happens when we try to compile this simple program? 58

59 prototypes (cont) When we try to compile the program this happens: This looks a lot like the warning we got when we didn t have the #include <stdio.h> 59

60 prototypes When the compiler sees this, it wants to know what addint is. 60

61 Fix One Defined before it is used. 61

62 Fix Two prototype added 62

63 Functions from special libraries Some library code is not linked in by default Examples: sqrt, ceil, sin, cos, tan, log, [math library] These require specifying to the compiler/linker that the math library needs to be linked in. You do this by adding lm at the end of the compiler invocation: gcc Wall foo.c lm linker command to add math library Libraries that need to be linked in explicitly like this are indicated in the man pages. 63

64 void We ve said in C there are no procedures just functions. Every function returns a value, but what if I don t need/want a value returned? For example, suppose I have a function that just prints hi. I can declare that function as type void 64

65 void 65

66 void Function returns no value 66

67 void Function also has no parameters. 67

68 void Optional way to indicate that the function also has no parameters. 68

69 printing to stderr The assignments ask you to print error messages to standard error. To do this you use fprintf fprintf works like printf except that printf always prints to stdout and you tell fprintf where to print: To print an error to stderr: fprintf(stderr, "I'm an error\n"); 69

70 printing to stderr Note that printf("hi!\n"); and fprintf(stdout,"hi\n"); do exactly the same thing. 70

71 Returning from an error Remember that in the assignments, when your program exits, if it has seen an error it should not return 0. The catch is sometimes your program will continue to run after getting a bad input. It must remember it has seen the error and return the correct value. 71

72 Characters and strings A character is of type char (signed or unsigned) C99 provides support for wide characters strings : an array of characters terminated by a 0 character ( NULL : written \0 ) string operations are provided through libraries (they are not part of the language) C arrays don t have bound-checking careless programming can give rise to memory-corruption errors 72

73 Example of string manipulation declares an array of chars print out a string (%s) the input analog to printf: read a value into str (%s = string ) 73

74 More strings waits for input (from stdin) typed in on keyboard: stdin program output (stdout) end-of-file indicated by typing Ctrl-D 74

75 More strings Oops! this means the program tried to access an illegal memory address 75

76 limiting string size using scanf() So how can we avoid the errors on the previous slide? By using the conversion %ns with scanf() the size of the string read is limited to n Be sure the buffer being read into is size n + 1 to allow for the null terminator at the end. 76

77 Protecting String Inputs limits the number of chars input to 31 77

78 The new output program only read first 31 chars in the string The remainder of the string was read the next time through the loop. 78

79 More detail So strings are arrays of characters (that end with a NULL ( \0 )) But what is a character? A character is a byte of data. This can be viewed either as a (small) number or as a symbol from the ASCII table. To specify a character in C use single quotes: char c; c = b ; 79

80 So even though characters can be thought of as letters, digits, or symbols, you can also use addition, subtraction, multiplication, etc. on them. You can also compare them: A < G evaluates to true. The uppercase letters and lower case letters run in a sequence. i.e.: c + 1 == d 80

81 How can we use this to write a test if a character c is a capital letter? 81

82 How can we use this to write a test if a character c is a upper case letter? if (c >= A && c <= Z ) { // if c is an uppercase letter then we go here } Let s write a function to convert all the lowercase letters of a string to upper case. 82

83 The completed program 83

84 Initializing Strings char str1[50] = I am the walrus. //puts string in str char str2[] = I am the walrus. // allocates array of size 17 and stores string same as char str2[17] = I am the walrus. char *str3 = I am the walrus. //points str3 at the STRING CONSTANT I am the walrus. //it is legal to read str3 but not to write to the memory //it points to! 84

85 Reading a line at a time scanf is nice. It parses the input and converts it to integers, floating points, etc. Sometimes we want to read a line at a time from the input. scanf is not so great for that. Fortunately there are functions that do read in a line at a time from the input. Two of them are: getline() fgets() 85

86 getline 86

87 getline 87

88 getline (code example) #include <stdio.h> #include <stdlib.h> int main(void) { int block = 1; char* line = NULL; size_t len = 0; while (getline(&line, &len, stdin)!= EOF) { /* Because we read as many characters as needed (subject to available * memory), we will generally have a return in line, and so we do not * want one in the printf(). */ printf("line %03d: %s", block, line); block++; } /* * When we are done with it, we free line. This will become much more clear * in a few weeks. */ free(line); } return 0; 88

89 getline The nice thing about getline is that it allocates the memory you need for you. You don t have to worry about the input being to big to fit in the memory you ve allocated. The bad thing about getline is that it is a gnu extension and is not available for all systems. (It is available on most systems including lectura though) 89

90 fgets 90

91 fgets 91

92 fgets (coding example) #include <stdio.h> int main(void) { int block = 1; char buff[ 10 ]; /* * Unfortunately, fgets() returns NULL both on EOF and on error. We could * use ferror() and feof() to distinguish these, but for the example we will * assume that error on read is rare enough for demos. */ while (fgets(buff, sizeof(buff), stdin)!= NULL) { /* When we get to ends of lines, we will output an extra return * because fgets() puts the end of line into the buffer. */ printf("block %03d: %s\n", block, buff); block++; } } return 0; 92

93 fgets The nice thing about fgets() is that it s a standard c function and should be available on all systems. The bad thing is that you have to provide the memory for the function to store the input lines into. Notice that one of the parameters to fgets is the maximum number of characters to be read in. (See how this is slightly different than scanf?) There is a fprintf() and printf() if I want to just print to stdout. Likewise there is a fscanf() to read from any stream and scanf() to just read from stdin. fgets() lets me read from any stream, can I use gets() when I just want to read from stdin? 93

94 Don t use gets()! Even the manual page says not to. So why is it in the library? 94

95 Don t use gets()! Even the manual page says not to. The reason for this confusion is that gets() is not simply fgets() with the stream argument set to stdin (the buffer size argument gets dropped). This is different from printf/fprintf and scanf/fscanf Flaws like this are hard to repair because significant code basis might break if you fixed them. 95

The C Programming Language course syllabus associate level

The C Programming Language course syllabus associate level TECHNOLOGIES The C Programming Language course syllabus associate level Course description The course fully covers the basics of programming in the C programming language and demonstrates fundamental programming

More information

Informatica e Sistemi in Tempo Reale

Informatica e Sistemi in Tempo Reale Informatica e Sistemi in Tempo Reale Introduction to C programming Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 25, 2010 G. Lipari (Scuola Superiore Sant Anna)

More information

CP Lab 2: Writing programs for simple arithmetic problems

CP Lab 2: Writing programs for simple arithmetic problems Computer Programming (CP) Lab 2, 2015/16 1 CP Lab 2: Writing programs for simple arithmetic problems Instructions The purpose of this Lab is to guide you through a series of simple programming problems,

More information

As previously noted, a byte can contain a numeric value in the range 0-255. Computers don't understand Latin, Cyrillic, Hindi, Arabic character sets!

As previously noted, a byte can contain a numeric value in the range 0-255. Computers don't understand Latin, Cyrillic, Hindi, Arabic character sets! Encoding of alphanumeric and special characters As previously noted, a byte can contain a numeric value in the range 0-255. Computers don't understand Latin, Cyrillic, Hindi, Arabic character sets! Alphanumeric

More information

Sources: On the Web: Slides will be available on:

Sources: On the Web: Slides will be available on: C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,

More information

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C Embedded Systems A Review of ANSI C and Considerations for Embedded C Programming Dr. Jeff Jackson Lecture 2-1 Review of ANSI C Topics Basic features of C C fundamentals Basic data types Expressions Selection

More information

So far we have considered only numeric processing, i.e. processing of numeric data represented

So far we have considered only numeric processing, i.e. processing of numeric data represented Chapter 4 Processing Character Data So far we have considered only numeric processing, i.e. processing of numeric data represented as integer and oating point types. Humans also use computers to manipulate

More information

The programming language C. sws1 1

The programming language C. sws1 1 The programming language C sws1 1 The programming language C invented by Dennis Ritchie in early 1970s who used it to write the first Hello World program C was used to write UNIX Standardised as K&C (Kernighan

More information

ASCII Encoding. The char Type. Manipulating Characters. Manipulating Characters

ASCII Encoding. The char Type. Manipulating Characters. Manipulating Characters The char Type ASCII Encoding The C char type stores small integers. It is usually 8 bits. char variables guaranteed to be able to hold integers 0.. +127. char variables mostly used to store characters

More information

arrays C Programming Language - Arrays

arrays C Programming Language - Arrays arrays So far, we have been using only scalar variables scalar meaning a variable with a single value But many things require a set of related values coordinates or vectors require 3 (or 2, or 4, or more)

More information

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program. Name: Class: Date: Exam #1 - Prep True/False Indicate whether the statement is true or false. 1. Programming is the process of writing a computer program in a language that the computer can respond to

More information

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T) Unit- I Introduction to c Language: C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating

More information

Module 816. File Management in C. M. Campbell 1993 Deakin University

Module 816. File Management in C. M. Campbell 1993 Deakin University M. Campbell 1993 Deakin University Aim Learning objectives Content After working through this module you should be able to create C programs that create an use both text and binary files. After working

More information

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner. Handout 1 CS603 Object-Oriented Programming Fall 15 Page 1 of 11 Handout 1 Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner. Java

More information

PHP Debugging. Draft: March 19, 2013 2013 Christopher Vickery

PHP Debugging. Draft: March 19, 2013 2013 Christopher Vickery PHP Debugging Draft: March 19, 2013 2013 Christopher Vickery Introduction Debugging is the art of locating errors in your code. There are three types of errors to deal with: 1. Syntax errors: When code

More information

C++ INTERVIEW QUESTIONS

C++ INTERVIEW QUESTIONS C++ INTERVIEW QUESTIONS http://www.tutorialspoint.com/cplusplus/cpp_interview_questions.htm Copyright tutorialspoint.com Dear readers, these C++ Interview Questions have been designed specially to get

More information

Simple C Programs. Goals for this Lecture. Help you learn about:

Simple C Programs. Goals for this Lecture. Help you learn about: Simple C Programs 1 Goals for this Lecture Help you learn about: Simple C programs Program structure Defining symbolic constants Detecting and reporting failure Functionality of the gcc command Preprocessor,

More information

CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals

CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals 1 Recall From Last Time: Java Program import java.util.scanner; public class EggBasket { public static void main(string[]

More information

Memory management. Announcements. Safe user input. Function pointers. Uses of function pointers. Function pointer example

Memory management. Announcements. Safe user input. Function pointers. Uses of function pointers. Function pointer example Announcements Memory management Assignment 2 posted, due Friday Do two of the three problems Assignment 1 graded see grades on CMS Lecture 7 CS 113 Spring 2008 2 Safe user input If you use scanf(), include

More information

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013 Oct 4, 2013, p 1 Name: CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013 1. (max 18) 4. (max 16) 2. (max 12) 5. (max 12) 3. (max 24) 6. (max 18) Total: (max 100)

More information

5 Arrays and Pointers

5 Arrays and Pointers 5 Arrays and Pointers 5.1 One-dimensional arrays Arrays offer a convenient way to store and access blocks of data. Think of arrays as a sequential list that offers indexed access. For example, a list of

More information

We will learn the Python programming language. Why? Because it is easy to learn and many people write programs in Python so we can share.

We will learn the Python programming language. Why? Because it is easy to learn and many people write programs in Python so we can share. LING115 Lecture Note Session #4 Python (1) 1. Introduction As we have seen in previous sessions, we can use Linux shell commands to do simple text processing. We now know, for example, how to count words.

More information

Java Interview Questions and Answers

Java Interview Questions and Answers 1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write and compile the java

More information

System Calls and Standard I/O

System Calls and Standard I/O System Calls and Standard I/O Professor Jennifer Rexford http://www.cs.princeton.edu/~jrex 1 Goals of Today s Class System calls o How a user process contacts the Operating System o For advanced services

More information

Illustration 1: Diagram of program function and data flow

Illustration 1: Diagram of program function and data flow The contract called for creation of a random access database of plumbing shops within the near perimeter of FIU Engineering school. The database features a rating number from 1-10 to offer a guideline

More information

First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science

First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science First Java Programs V. Paúl Pauca Department of Computer Science Wake Forest University CSC 111D Fall, 2015 Hello World revisited / 8/23/15 The f i r s t o b l i g a t o r y Java program @author Paul Pauca

More information

Introduction to Java Applications. 2005 Pearson Education, Inc. All rights reserved.

Introduction to Java Applications. 2005 Pearson Education, Inc. All rights reserved. 1 2 Introduction to Java Applications 2.2 First Program in Java: Printing a Line of Text 2 Application Executes when you use the java command to launch the Java Virtual Machine (JVM) Sample program Displays

More information

Moving from CS 61A Scheme to CS 61B Java

Moving from CS 61A Scheme to CS 61B Java Moving from CS 61A Scheme to CS 61B Java Introduction Java is an object-oriented language. This document describes some of the differences between object-oriented programming in Scheme (which we hope you

More information

University of Hull Department of Computer Science. Wrestling with Python Week 01 Playing with Python

University of Hull Department of Computer Science. Wrestling with Python Week 01 Playing with Python Introduction Welcome to our Python sessions. University of Hull Department of Computer Science Wrestling with Python Week 01 Playing with Python Vsn. 1.0 Rob Miles 2013 Please follow the instructions carefully.

More information

Member Functions of the istream Class

Member Functions of the istream Class Member Functions of the istream Class The extraction operator is of limited use because it always uses whitespace to delimit its reads of the input stream. It cannot be used to read those whitespace characters,

More information

Introduction to Data Structures

Introduction to Data Structures Introduction to Data Structures Albert Gural October 28, 2011 1 Introduction When trying to convert from an algorithm to the actual code, one important aspect to consider is how to store and manipulate

More information

Base Conversion written by Cathy Saxton

Base Conversion written by Cathy Saxton Base Conversion written by Cathy Saxton 1. Base 10 In base 10, the digits, from right to left, specify the 1 s, 10 s, 100 s, 1000 s, etc. These are powers of 10 (10 x ): 10 0 = 1, 10 1 = 10, 10 2 = 100,

More information

Python Loops and String Manipulation

Python Loops and String Manipulation WEEK TWO Python Loops and String Manipulation Last week, we showed you some basic Python programming and gave you some intriguing problems to solve. But it is hard to do anything really exciting until

More information

Java CPD (I) Frans Coenen Department of Computer Science

Java CPD (I) Frans Coenen Department of Computer Science Java CPD (I) Frans Coenen Department of Computer Science Content Session 1, 12:45-14:30 (First Java Programme, Inheritance, Arithmetic) Session 2, 14:45-16:45 (Input and Programme Constructs) Materials

More information

Beyond the Mouse A Short Course on Programming

Beyond the Mouse A Short Course on Programming 1 / 22 Beyond the Mouse A Short Course on Programming 2. Fundamental Programming Principles I: Variables and Data Types Ronni Grapenthin Geophysical Institute, University of Alaska Fairbanks September

More information

INTRODUCTION TO OBJECTIVE-C CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 12 09/29/2011

INTRODUCTION TO OBJECTIVE-C CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 12 09/29/2011 INTRODUCTION TO OBJECTIVE-C CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 12 09/29/2011 1 Goals of the Lecture Present an introduction to Objective-C 2.0 Coverage of the language will be INCOMPLETE

More information

VB.NET Programming Fundamentals

VB.NET Programming Fundamentals Chapter 3 Objectives Programming Fundamentals In this chapter, you will: Learn about the programming language Write a module definition Use variables and data types Compute with Write decision-making statements

More information

Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007

Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007 Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007 The Java Type System By now, you have seen a fair amount of Java. Time to study in more depth the foundations of the language,

More information

1 Abstract Data Types Information Hiding

1 Abstract Data Types Information Hiding 1 1 Abstract Data Types Information Hiding 1.1 Data Types Data types are an integral part of every programming language. ANSI-C has int, double and char to name just a few. Programmers are rarely content

More information

PART-A Questions. 2. How does an enumerated statement differ from a typedef statement?

PART-A Questions. 2. How does an enumerated statement differ from a typedef statement? 1. Distinguish & and && operators. PART-A Questions 2. How does an enumerated statement differ from a typedef statement? 3. What are the various members of a class? 4. Who can access the protected members

More information

Basics of I/O Streams and File I/O

Basics of I/O Streams and File I/O Basics of This is like a cheat sheet for file I/O in C++. It summarizes the steps you must take to do basic I/O to and from files, with only a tiny bit of explanation. It is not a replacement for reading

More information

Chapter 5 Names, Bindings, Type Checking, and Scopes

Chapter 5 Names, Bindings, Type Checking, and Scopes Chapter 5 Names, Bindings, Type Checking, and Scopes Chapter 5 Topics Introduction Names Variables The Concept of Binding Type Checking Strong Typing Scope Scope and Lifetime Referencing Environments Named

More information

1 Description of The Simpletron

1 Description of The Simpletron Simulating The Simpletron Computer 50 points 1 Description of The Simpletron In this assignment you will write a program to simulate a fictional computer that we will call the Simpletron. As its name implies

More information

What is a Loop? Pretest Loops in C++ Types of Loop Testing. Count-controlled loops. Loops can be...

What is a Loop? Pretest Loops in C++ Types of Loop Testing. Count-controlled loops. Loops can be... What is a Loop? CSC Intermediate Programming Looping A loop is a repetition control structure It causes a single statement or a group of statements to be executed repeatedly It uses a condition to control

More information

KITES TECHNOLOGY COURSE MODULE (C, C++, DS)

KITES TECHNOLOGY COURSE MODULE (C, C++, DS) KITES TECHNOLOGY 360 Degree Solution www.kitestechnology.com/academy.php info@kitestechnology.com technologykites@gmail.com Contact: - 8961334776 9433759247 9830639522.NET JAVA WEB DESIGN PHP SQL, PL/SQL

More information

C Programming. for Embedded Microcontrollers. Warwick A. Smith. Postbus 11. Elektor International Media BV. 6114ZG Susteren The Netherlands

C Programming. for Embedded Microcontrollers. Warwick A. Smith. Postbus 11. Elektor International Media BV. 6114ZG Susteren The Netherlands C Programming for Embedded Microcontrollers Warwick A. Smith Elektor International Media BV Postbus 11 6114ZG Susteren The Netherlands 3 the Table of Contents Introduction 11 Target Audience 11 What is

More information

File Handling. What is a file?

File Handling. What is a file? File Handling 1 What is a file? A named collection of data, stored in secondary storage (typically). Typical operations on files: Open Read Write Close How is a file stored? Stored as sequence of bytes,

More information

Advanced Bash Scripting. Joshua Malone (jmalone@ubergeeks.com)

Advanced Bash Scripting. Joshua Malone (jmalone@ubergeeks.com) Advanced Bash Scripting Joshua Malone (jmalone@ubergeeks.com) Why script in bash? You re probably already using it Great at managing external programs Powerful scripting language Portable and version-stable

More information

Keywords are identifiers having predefined meanings in C programming language. The list of keywords used in standard C are : unsigned void

Keywords are identifiers having predefined meanings in C programming language. The list of keywords used in standard C are : unsigned void 1. Explain C tokens Tokens are basic building blocks of a C program. A token is the smallest element of a C program that is meaningful to the compiler. The C compiler recognizes the following kinds of

More information

Basic Java Constructs and Data Types Nuts and Bolts. Looking into Specific Differences and Enhancements in Java compared to C

Basic Java Constructs and Data Types Nuts and Bolts. Looking into Specific Differences and Enhancements in Java compared to C Basic Java Constructs and Data Types Nuts and Bolts Looking into Specific Differences and Enhancements in Java compared to C 1 Contents Hello World Program Statements Explained Java Program Structure in

More information

How To Write Portable Programs In C

How To Write Portable Programs In C Writing Portable Programs COS 217 1 Goals of Today s Class Writing portable programs in C Sources of heterogeneity Data types, evaluation order, byte order, char set, Reading period and final exam Important

More information

The Hexadecimal Number System and Memory Addressing

The Hexadecimal Number System and Memory Addressing APPENDIX C The Hexadecimal Number System and Memory Addressing U nderstanding the number system and the coding system that computers use to store data and communicate with each other is fundamental to

More information

Introduction to Java

Introduction to Java Introduction to Java The HelloWorld program Primitive data types Assignment and arithmetic operations User input Conditional statements Looping Arrays CSA0011 Matthew Xuereb 2008 1 Java Overview A high

More information

Tutorial on C Language Programming

Tutorial on C Language Programming Tutorial on C Language Programming Teodor Rus rus@cs.uiowa.edu The University of Iowa, Department of Computer Science Introduction to System Software p.1/64 Tutorial on C programming C program structure:

More information

Topics. Parts of a Java Program. Topics (2) CS 146. Introduction To Computers And Java Chapter Objectives To understand:

Topics. Parts of a Java Program. Topics (2) CS 146. Introduction To Computers And Java Chapter Objectives To understand: Introduction to Programming and Algorithms Module 2 CS 146 Sam Houston State University Dr. Tim McGuire Introduction To Computers And Java Chapter Objectives To understand: the meaning and placement of

More information

Chapter 13 Storage classes

Chapter 13 Storage classes Chapter 13 Storage classes 1. Storage classes 2. Storage Class auto 3. Storage Class extern 4. Storage Class static 5. Storage Class register 6. Global and Local Variables 7. Nested Blocks with the Same

More information

UIL Computer Science for Dummies by Jake Warren and works from Mr. Fleming

UIL Computer Science for Dummies by Jake Warren and works from Mr. Fleming UIL Computer Science for Dummies by Jake Warren and works from Mr. Fleming 1 2 Foreword First of all, this book isn t really for dummies. I wrote it for myself and other kids who are on the team. Everything

More information

PROBLEM SOLVING SEVENTH EDITION WALTER SAVITCH UNIVERSITY OF CALIFORNIA, SAN DIEGO CONTRIBUTOR KENRICK MOCK UNIVERSITY OF ALASKA, ANCHORAGE PEARSON

PROBLEM SOLVING SEVENTH EDITION WALTER SAVITCH UNIVERSITY OF CALIFORNIA, SAN DIEGO CONTRIBUTOR KENRICK MOCK UNIVERSITY OF ALASKA, ANCHORAGE PEARSON PROBLEM SOLVING WITH SEVENTH EDITION WALTER SAVITCH UNIVERSITY OF CALIFORNIA, SAN DIEGO CONTRIBUTOR KENRICK MOCK UNIVERSITY OF ALASKA, ANCHORAGE PEARSON Addison Wesley Boston San Francisco New York London

More information

Semantic Analysis: Types and Type Checking

Semantic Analysis: Types and Type Checking Semantic Analysis Semantic Analysis: Types and Type Checking CS 471 October 10, 2007 Source code Lexical Analysis tokens Syntactic Analysis AST Semantic Analysis AST Intermediate Code Gen lexical errors

More information

public static void main(string[] args) { System.out.println("hello, world"); } }

public static void main(string[] args) { System.out.println(hello, world); } } Java in 21 minutes hello world basic data types classes & objects program structure constructors garbage collection I/O exceptions Strings Hello world import java.io.*; public class hello { public static

More information

grep, awk and sed three VERY useful command-line utilities Matt Probert, Uni of York grep = global regular expression print

grep, awk and sed three VERY useful command-line utilities Matt Probert, Uni of York grep = global regular expression print grep, awk and sed three VERY useful command-line utilities Matt Probert, Uni of York grep = global regular expression print In the simplest terms, grep (global regular expression print) will search input

More information

C / C++ and Unix Programming. Materials adapted from Dan Hood and Dianna Xu

C / C++ and Unix Programming. Materials adapted from Dan Hood and Dianna Xu C / C++ and Unix Programming Materials adapted from Dan Hood and Dianna Xu 1 C and Unix Programming Today s goals ú History of C ú Basic types ú printf ú Arithmetic operations, types and casting ú Intro

More information

Lab 4: Socket Programming: netcat part

Lab 4: Socket Programming: netcat part Lab 4: Socket Programming: netcat part Overview The goal of this lab is to familiarize yourself with application level programming with sockets, specifically stream or TCP sockets, by implementing a client/server

More information

Exceptions in MIPS. know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine

Exceptions in MIPS. know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine 7 Objectives After completing this lab you will: know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine Introduction Branches and jumps provide ways to change

More information

Introduction to Python

Introduction to Python WEEK ONE Introduction to Python Python is such a simple language to learn that we can throw away the manual and start with an example. Traditionally, the first program to write in any programming language

More information

VHDL Test Bench Tutorial

VHDL Test Bench Tutorial University of Pennsylvania Department of Electrical and Systems Engineering ESE171 - Digital Design Laboratory VHDL Test Bench Tutorial Purpose The goal of this tutorial is to demonstrate how to automate

More information

Java Basics: Data Types, Variables, and Loops

Java Basics: Data Types, Variables, and Loops Java Basics: Data Types, Variables, and Loops If debugging is the process of removing software bugs, then programming must be the process of putting them in. - Edsger Dijkstra Plan for the Day Variables

More information

Lecture 22: C Programming 4 Embedded Systems

Lecture 22: C Programming 4 Embedded Systems Lecture 22: C Programming 4 Embedded Systems Today s Goals Basic C programming process Variables and constants in C Pointers to access addresses Using a High Level Language High-level languages More human

More information

Computer Science 281 Binary and Hexadecimal Review

Computer Science 281 Binary and Hexadecimal Review Computer Science 281 Binary and Hexadecimal Review 1 The Binary Number System Computers store everything, both instructions and data, by using many, many transistors, each of which can be in one of two

More information

FEEG6002 - Applied Programming 5 - Tutorial Session

FEEG6002 - Applied Programming 5 - Tutorial Session FEEG6002 - Applied Programming 5 - Tutorial Session Sam Sinayoko 2015-10-30 1 / 38 Outline Objectives Two common bugs General comments on style String formatting Questions? Summary 2 / 38 Objectives Revise

More information

Everything you wanted to know about using Hexadecimal and Octal Numbers in Visual Basic 6

Everything you wanted to know about using Hexadecimal and Octal Numbers in Visual Basic 6 Everything you wanted to know about using Hexadecimal and Octal Numbers in Visual Basic 6 Number Systems No course on programming would be complete without a discussion of the Hexadecimal (Hex) number

More information

Pemrograman Dasar. Basic Elements Of Java

Pemrograman Dasar. Basic Elements Of Java Pemrograman Dasar Basic Elements Of Java Compiling and Running a Java Application 2 Portable Java Application 3 Java Platform Platform: hardware or software environment in which a program runs. Oracle

More information

Simple C++ Programs. Engineering Problem Solving with C++, Etter/Ingber. Dev-C++ Dev-C++ Windows Friendly Exit. The C++ Programming Language

Simple C++ Programs. Engineering Problem Solving with C++, Etter/Ingber. Dev-C++ Dev-C++ Windows Friendly Exit. The C++ Programming Language Simple C++ Programs Engineering Problem Solving with C++, Etter/Ingber Chapter 2 Simple C++ Programs Program Structure Constants and Variables C++ Operators Standard Input and Output Basic Functions from

More information

Introduction to UNIX and SFTP

Introduction to UNIX and SFTP Introduction to UNIX and SFTP Introduction to UNIX 1. What is it? 2. Philosophy and issues 3. Using UNIX 4. Files & folder structure 1. What is UNIX? UNIX is an Operating System (OS) All computers require

More information

The Java Series. Java Essentials I What is Java? Basic Language Constructs. Java Essentials I. What is Java?. Basic Language Constructs Slide 1

The Java Series. Java Essentials I What is Java? Basic Language Constructs. Java Essentials I. What is Java?. Basic Language Constructs Slide 1 The Java Series Java Essentials I What is Java? Basic Language Constructs Slide 1 What is Java? A general purpose Object Oriented programming language. Created by Sun Microsystems. It s a general purpose

More information

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. Exam Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) The JDK command to compile a class in the file Test.java is A) java Test.java B) java

More information

C++ Programming Language

C++ Programming Language C++ Programming Language Lecturer: Yuri Nefedov 7th and 8th semesters Lectures: 34 hours (7th semester); 32 hours (8th semester). Seminars: 34 hours (7th semester); 32 hours (8th semester). Course abstract

More information

GDB Tutorial. A Walkthrough with Examples. CMSC 212 - Spring 2009. Last modified March 22, 2009. GDB Tutorial

GDB Tutorial. A Walkthrough with Examples. CMSC 212 - Spring 2009. Last modified March 22, 2009. GDB Tutorial A Walkthrough with Examples CMSC 212 - Spring 2009 Last modified March 22, 2009 What is gdb? GNU Debugger A debugger for several languages, including C and C++ It allows you to inspect what the program

More information

CS1020 Data Structures and Algorithms I Lecture Note #1. Introduction to Java

CS1020 Data Structures and Algorithms I Lecture Note #1. Introduction to Java CS1020 Data Structures and Algorithms I Lecture Note #1 Introduction to Java Objectives Java Basic Java features C Java Translate C programs in CS1010 into Java programs 2 References Chapter 1 Section

More information

Object Oriented Software Design

Object Oriented Software Design Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa September 14, 2011 G. Lipari (Scuola Superiore Sant Anna) Introduction

More information

Object Oriented Software Design

Object Oriented Software Design Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 28, 2010 G. Lipari (Scuola Superiore Sant Anna) Introduction

More information

Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C

Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C 1 An essential part of any embedded system design Programming 2 Programming in Assembly or HLL Processor and memory-sensitive

More information

Lecture 5: Java Fundamentals III

Lecture 5: Java Fundamentals III Lecture 5: Java Fundamentals III School of Science and Technology The University of New England Trimester 2 2015 Lecture 5: Java Fundamentals III - Operators Reading: Finish reading Chapter 2 of the 2nd

More information

Number Representation

Number Representation Number Representation CS10001: Programming & Data Structures Pallab Dasgupta Professor, Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur Topics to be Discussed How are numeric data

More information

CS101 Lecture 11: Number Systems and Binary Numbers. Aaron Stevens 14 February 2011

CS101 Lecture 11: Number Systems and Binary Numbers. Aaron Stevens 14 February 2011 CS101 Lecture 11: Number Systems and Binary Numbers Aaron Stevens 14 February 2011 1 2 1 3!!! MATH WARNING!!! TODAY S LECTURE CONTAINS TRACE AMOUNTS OF ARITHMETIC AND ALGEBRA PLEASE BE ADVISED THAT CALCULTORS

More information

How To Port A Program To Dynamic C (C) (C-Based) (Program) (For A Non Portable Program) (Un Portable) (Permanent) (Non Portable) C-Based (Programs) (Powerpoint)

How To Port A Program To Dynamic C (C) (C-Based) (Program) (For A Non Portable Program) (Un Portable) (Permanent) (Non Portable) C-Based (Programs) (Powerpoint) TN203 Porting a Program to Dynamic C Introduction Dynamic C has a number of improvements and differences compared to many other C compiler systems. This application note gives instructions and suggestions

More information

About The Tutorial. Audience. Prerequisites. Copyright & Disclaimer

About The Tutorial. Audience. Prerequisites. Copyright & Disclaimer About The Tutorial C is a general-purpose, procedural, imperative computer programming language developed in 1972 by Dennis M. Ritchie at the Bell Telephone Laboratories to develop the UNIX operating system.

More information

CSI 402 Lecture 13 (Unix Process Related System Calls) 13 1 / 17

CSI 402 Lecture 13 (Unix Process Related System Calls) 13 1 / 17 CSI 402 Lecture 13 (Unix Process Related System Calls) 13 1 / 17 System Calls for Processes Ref: Process: Chapter 5 of [HGS]. A program in execution. Several processes are executed concurrently by the

More information

Introduction to Python

Introduction to Python Caltech/LEAD Summer 2012 Computer Science Lecture 2: July 10, 2012 Introduction to Python The Python shell Outline Python as a calculator Arithmetic expressions Operator precedence Variables and assignment

More information

Chapter 2: Elements of Java

Chapter 2: Elements of Java Chapter 2: Elements of Java Basic components of a Java program Primitive data types Arithmetic expressions Type casting. The String type (introduction) Basic I/O statements Importing packages. 1 Introduction

More information

Chapter One Introduction to Programming

Chapter One Introduction to Programming Chapter One Introduction to Programming 1-1 Algorithm and Flowchart Algorithm is a step-by-step procedure for calculation. More precisely, algorithm is an effective method expressed as a finite list of

More information

Part 1 Foundations of object orientation

Part 1 Foundations of object orientation OFWJ_C01.QXD 2/3/06 2:14 pm Page 1 Part 1 Foundations of object orientation OFWJ_C01.QXD 2/3/06 2:14 pm Page 2 1 OFWJ_C01.QXD 2/3/06 2:14 pm Page 3 CHAPTER 1 Objects and classes Main concepts discussed

More information

Lecture 2. Binary and Hexadecimal Numbers

Lecture 2. Binary and Hexadecimal Numbers Lecture 2 Binary and Hexadecimal Numbers Purpose: Review binary and hexadecimal number representations Convert directly from one base to another base Review addition and subtraction in binary representations

More information

ECS 165B: Database System Implementa6on Lecture 2

ECS 165B: Database System Implementa6on Lecture 2 ECS 165B: Database System Implementa6on Lecture 2 UC Davis, Spring 2011 Por6ons of slides based on earlier ones by Raghu Ramakrishnan, Johannes Gehrke, Jennifer Widom, Bertram Ludaescher, and Michael Gertz.

More information

An Introduction to Assembly Programming with the ARM 32-bit Processor Family

An Introduction to Assembly Programming with the ARM 32-bit Processor Family An Introduction to Assembly Programming with the ARM 32-bit Processor Family G. Agosta Politecnico di Milano December 3, 2011 Contents 1 Introduction 1 1.1 Prerequisites............................. 2

More information

Programming Languages

Programming Languages Programming Languages Programming languages bridge the gap between people and machines; for that matter, they also bridge the gap among people who would like to share algorithms in a way that immediately

More information

Chapter 4: Computer Codes

Chapter 4: Computer Codes Slide 1/30 Learning Objectives In this chapter you will learn about: Computer data Computer codes: representation of data in binary Most commonly used computer codes Collating sequence 36 Slide 2/30 Data

More information

6 3 4 9 = 6 10 + 3 10 + 4 10 + 9 10

6 3 4 9 = 6 10 + 3 10 + 4 10 + 9 10 Lesson The Binary Number System. Why Binary? The number system that you are familiar with, that you use every day, is the decimal number system, also commonly referred to as the base- system. When you

More information

Tutorial on Socket Programming

Tutorial on Socket Programming Tutorial on Socket Programming Computer Networks - CSC 458 Department of Computer Science Seyed Hossein Mortazavi (Slides are mainly from Monia Ghobadi, and Amin Tootoonchian, ) 1 Outline Client- server

More information

AP Computer Science Java Subset

AP Computer Science Java Subset APPENDIX A AP Computer Science Java Subset The AP Java subset is intended to outline the features of Java that may appear on the AP Computer Science A Exam. The AP Java subset is NOT intended as an overall

More information