Instructor : Stan Kong
|
|
- Mitchell Chapman
- 7 years ago
- Views:
Transcription
1 ET2560 Introduction to C Programming Mid Term Review Instructor : Stan Kong skong@itt tech.edutech.edu
2 Computers and Programs Computer A machine that processes data under the control of a stored program Requires hardware, software, and data Program A series of instructions that guide a computer through a process
3 Figure 1.3 Components of a Computer
4 Central Processing Unit Central Processing Unit (CPU) has tworoles: coordinating all computer operations and performing arithmetic and logical operations on data.
5 Main Memory Main memorystores programs, data and results. Most computers have two types of main memory: random access memory (RAM) and read only memory (ROM). RAM which offer temporary storage of program and data. RAM is usually volatile memory, which means that everything in RAM will be lost when the computer is switched off. ROM which stores programs or data permanently, it is not volatile. Thecomputer can read, but cannot write information in ROM.
6 Secondary Storage Devices Computer systems provide storage in addition to main memory for two reason. First, computers need storage that is permanent so that information can be retained during a power loss of when computer is turn off. Second, systems typically store more information than will fit in memory.
7 Input/Output Devices Input/output devices are use to communicate with the computer. Specifically they allow us to enter data for a computation and to observe the results of that computation. For example, keyboard is an input device and a monitor is an output device.
8 The operating system is a set of system software routines that interface between an application program and the hardware. It is responsible to manage processor resource and memory resource and load program into memory. User Application program Operating system Computer Hardware
9 Machine languages are the only languages understood by computers. While easily understood by computers, machine languages are almost impossible for humans to use because they consist it entirely of numbers. A compiler converts each source statement to one or more machine level instructions (machine languages). Library Linker Executable Program
10 Begin and End Shapes These shapes are used to begin and end a flowchart The beginning shape has the algorithm name as its label The end shape contains the word End
11 Rectangle Shape Actions Rectangle has one entry and one exit The text in the rectangle is pseudo code corresponding to one step in the algorithm
12 Diamond Shape Decision Point One entry, two exits (one for yes, the other for no ) Contains one question, with yes/no answer
13 Selection Shape Selection is an extension of the decision point Instead of a question, the diamond contains a value The value selects which branch to take One other branch is used for all other values that don t have a branch
14 Connector Shape On page Use for a connection on same page Shape shows connection from one point to another Left shape can be used multiple times Right shape, used once, shows the destination of connection
15 Shapes Combine to Create Structures Straight line structure Single sided branch Double sided branch Selection structure Until loop While loop Do while loop
16 Straight line Structure
17 Single sided Branch
18 Double sided Branch
19 Selection Structure Selection structure is an extension of the branch All branches must converge together at the end
20 First C Program #include <stdio.h> /* printf, scanf definitions */ Int main(void) { } printf( Hello World.\n"); return (0);
21 General Form of a C program preprocessor directives main function heading { } declarations executable statements
22 Function main The point at which program execution begins Contains declarations and executable statements Standard format is: int main(void) { /*declarations*/ */ } /*executable statements*/ return (0);
23 Preprocessor Directives Provide instructions to the preprocessor. Begin with # #include Used to load a library, such as a standard librar #include <stdio.h> /* library needed for scanf, prinf function */ #define Used to define a constant macro Used to define a constant macro #define PI
24 Comments Comments can be written anywhere in the code: any characters between /* and */ are ignored by the compiler and can be used to make the code easier to understand. For example : portion of 1 st line begin with /* to */ are comments #include <stdio.h> /* printf, scanf library definitions */ Int main(void) id) { } printf( Hello World.\n"); return (0);
25 Declarations Statement Variable declarations Thememorycells used for storing a program s input data, output data and its computational results are called variables. The variable declarations tell the C compiler the names of all variables and what kind of information will be stored in each variable. The general format for variable declaration is: Data type variable name or variable list; Example : int count; where int is data type of integer and count is the variable name.
26 Data type Common data type int store integer char store single character Double store real number/floating number
27 String Constants Defined A string constant is zero or more characters (A string constant can be empty) Each character takes one byte in memory (An extra zero byte is used in memory at the end of a string) Each character is encoded using the ASCII code A string constant must begin and end with a double quote (The quote characters are not stored in memory)
28 String Constants Examples "Hello World" "Hello" and "Hello " are different "134.5" is not a number, it's a string "!@#$%;" is a string containing punctuation characters "" is the empty string " " is a string consisting of a space; it's not empty py "AF" and "af" are different case sensitive
29 String Escape Sequences Put special characters in a string or character constant Sequence of characters, starting with backslash \ Put quote or double quote in a string or character constant "\"Hi!\", we said." Single string of 15 characters Put a backslash in a string or character constant "\\" A string with one backslash character Put special codes in a string or character constant "\n" Makes console output start a new line "\t" Outputs a tab character '\g' Make a "beep" noise from the speaker
30 The printf( ) Function Function accepts one or more inputs (called arguments) First argument is a string (called format string) Format string can contain: Text One or more format placeholders, mixed in with text The official name of a format placeholder is a conversion specifier Format placeholders begin with a % character Placeholders ld are only understood dby printf, in its 1 st argument The formatted text prints on the console screen
31 Conversion Specifiers for printf( ) Formatting an int: %d Format as decimal integer 27 %b Format asbinaryinteger integer %x Format as hexadecimal integer 1b %X Format as hex integer using uppercase 1B Formatting a float or double: %f Format as decimal fraction %e Format as scientific notation 1.25e 1 %E Same as %e but with capital E 1.25E 1 Formatting a character: %c Format asaa single character x Formatting a string: %s Format as a string xyzzy g y y For a '%' character must use %%
32 Variables/User Defined Identifiers A variable may be defined using any uppercase or lowercase character, a numerical digit (0 through 9), and the underscore character (_). The first character of the variable may not be a numerical digit or underscore. C reserved word cannot be used as an variable name. Variable names are case sensitive. Valid identifiers letter_1, cent, Hello, Invalid identifier 1Letter double Two*Four big mac Reason invalid Begin with a letter Reserve word Character * not allowed Space is not allowed
33 C Reserved Words auto double include static break elif int struct case else long switch char enum main typedef const extern register union continue float return unsigned default for short void define goto signed volatile do if sizeof while
34 C Program Example with variables #include <stdio.h> /* library definition needed for scanf, prinf function */ #define PI /* Constant needed for circle */ /*This program accepts the radius of a circle, calculates the area, and outputs the radius and the area. */ int main(void) { double radius; /*Stores the radius entered by the user*/ double area; /*Stores the area after the calculation*/ } return (0);
35 Executable Statements An assignment Statements store a value or computational result in a variable, and is used to perform most arithmetic operations in a program. Example : abc = 25; /* assign abc to 25 */ abd = abc + 5 ; kms = KMS_PER_MILE * miles;
36 Input/output functions printf an output function from the I/O (input/output) library (defined in the file stdio.h). scanf an input function from the I/O (input/output) library (defined in thefile stdio.h).
37 scanf Function scanf(format string, input list); For example : scanf("%lf", &miles); Read the floating value into the address of the memory cell referenced dby the variable ibl name miles. Use %d for integer variable and %lf for floating point number variable. The name of each variable that is to be given in value is proceeded by & character.
38 printf Function Prinf(format string, print list); Prinf(format string); function arguments printf("that equals %f kilometers.\n", kms); function name format string print list That equals kilometers
39 C Program Example #include <stdio.h> #define PI /*This program accepts the radius of a circle, calculates the area, and outputs the radius and the area.*/ int main(void) { /*declarations*/ double radius; /*Stores the radius entered dby the user*/ double area; /*Stores the area after the calculation*/ /*executable statements*/ printf("enter the radius of the circle>"); /* output prompt */ scanf("%lf", &radius); /* input radius in floating point format */ area = PI * radius * radius; /*Calculates the area as PI X radius X radius and stores the results in area*/ printf("the area of a circle with a radius of %f is %f\n", radius, area); return (0); }
40 The Software Development Method 1. Specify the problem requirements. 2. Analyze the problem. 3. Design the algorithm to solve the problem. 4. Implement the algorithm. 5. Test and verify the completed program. 6. Maintain and updatetheprogram the program.
41 Algorithm to Program Include required libraries Define constants Declare variables Get the input Perform process to transform input tinto the output Display output t Refine the program
42 Table Arithmetic Operators
43 Unary vs. Binary Operators Unary Operators Binary Operators Take one operand Take two operands Negation ( ) operator Subtraction Plus (+) operator Addition Examples Multiplication x = -y; Division p = +x * y; Examples x = y + z; z = y z;
44 Rules of Precedence Parentheses rule Expressions in parentheses are evaluated separately. Nested parentheses are evaluated from the inside out. Operator precedence rule 1.unary +, 2.*, /, % 3.binary +, Associativity rule Unaryoperators at thesame level are evaluated right to left. Binary operators at the same level are evaluated left to right.
45 Expression Assignment Assignment can cause data to be lost if target variable is of a data type more narrow than the expression double x; int n; x = 9 * 0.5; n = 9 * 0.5; x n
46 Data Type Expression Example m = 3; n = 2; p = 2.0; x = m / p; y = m / n;
47 Casting a Variable's Type
48 Formatting Output of Type int use in prinf output tfunction Table 2.11 Displaying 234 and 234 Using Different Placeholders
49 Formatting Output of Type double use in prinf output function Table 2.13
50 Interactive Mode vs. Batch Mode Interactive Mode Accepts input from users Sends output to the display Batch Mode Accepts input from a file metric <mydata Should echo input using printf Might output data to a file metric >myoutput
51 Input redirection/output redirection Redirect input from file instead of keyboard EXAMPLE : metric metric <mydata Redirect output to a file EXAMPLE : metric >myoutput
52 Program Controlled input and output Files Declare a file pointer variable in which to store the information necessary to permit access to a file. File pointer variable are of type FILE *. Example : FILE *inp, /* pointer to input file */ *opt; /* pointer to output file */ Prepare file to open for read, write inp = fopen("distance distance.dat dat", "r"); r); opt = fopen("distance.out", "w");
53 Interactive program example /* Converts distances from miles to kilometers. */ #include <stdio.h> /* printf, scanf definitions */ #define KMS_PER_MILE /* conversion constant */ Int main(void) { double miles, /* distance in miles */ kms; /* equivalent distance in kilometers */ /* Get and echo the distance in miles. */ printf("enter Distance in miles is "); scanf( "%lf", &miles); printf("the distance in miles is %.2f.\n", miles); /* Convert the distance to kilometers. */ kms = KMS_PER_MILE * miles; /* Display the distance in kilometers. */ printf( "That equals %.2f kilometers.\n", kms); return (0); }
54
55 Syntax Errors Code violates a grammar error of C Compiler locates syntax errors during translation Examples: Missing semicolon Undeclared variables Unclosed comments Mismatched open and close braces, quotation marks, or parentheses
56 Runtime Error Detected during program execution Caused by an attempt to perform an illegal operation
57 Logic Errors Errors in the algorithm Causes program to give incorrect results Avoid idby desk checking ki algorithm before bf coding
58 Top Down Design A problem solving method in which you first break a problem into its major subproblems and then solve the subproblems to derive the solution to the original problem. Structure Chart A documentation tool that shows the relationships among the subproblems of a problem.
59 1 59 C Language Elements in Miles to Kilometers Conversion Program
60 Relational and Equality Operators Table 4 1
61 Table 4 2 Sample Conditions
62 Logical Operators And && (temperature > 90) && (humidity > 0.90) Or (salary < MIN_SALARY) (dependents > 5) Not!!(0 <= n && n <= 100)
63 Table 4.6 Operator Precedence
64 Sequential Flow A set of steps that are executed sequentially { statement; statement; statement; } statement statement statement
65 Selection Control Structure Eectionpath Execution changes based on a condition F Condition T Do this Do something else
66
67 Table 4.8 Character Comparisons
68 if Statement with One Alternative if (condition) action to perform if true; if (R!= 0.0) current = voltage / R;
69 if Statement with Two Alternatives if (condition) else action to perform if true; action to perform if false; if (voltage > 3.33 ) printf( A digital High is present!"\n); else printf( A digital Low is present!\n");
70 Blocks if (condition) { statement; statement; } else { statement; statement; } if (condition) { statement; statement; } else { statement; statement; }
71 Nested if Statements if (x > 0) num = num + 1; else { } if (x < 0) num_neg = num_neg + 1; else /* x equals 0 */ num_ zero = num_ zero + 1;
72 Multiple Alternative if Statements /* Display perception of noise loudness */ if (noise_db <= 50) printf( %d decibel noise is quiet.\n, noise_db); else if (noise_db <=70) printf( %d decibal noise is intrusive. \n, noise_db); else if (noise_db <= 90) printf( %d decibel noise is annoying.\n, noise_db); else if (noise_db <= 110) printf( %d decibel noise is very annoying. \n, noise_db); else printf( %d decible noise is uncomfortable. \n, noise_db);
73 Switch Statement The switch statement is used in C to select one of several alternatives. The switch statement is especially useful when the selection is based on the value of a single variable or a simple expression ( called the controlling expression). The value of this expression may be of type int or char, but not of type double. SYNTAX: switch (controlling expression) { label set1 statements1, break; label set2 statements2, break; label setn statementsn, break; default : statementsd, break; } label setn is case constant value :
74 Switch and Flowchart double discount; // Usually code would be read in char code = 'B' ; switch ( code ) { case 'A': discount = 0.0; break; } case 'B': discount = 0.1; break; case 'C': discount = 0.2; break; default: discount = 0.3;
75 Basics of Loops Programming gloops are iterative code structures A set of instructions is repeated a number of times Loops are controlled by a condition, or loop test A loop is preceded by an initialization Sets up the loop condition for initial execution A loop contains an increment Determines whether the loop continues or stops Loops without a loop test repeat indefinitely Useful for control systems or systems that "run continuously"
76 Loop Structures The "while" Loop Loop test is done first, at "top" of loop May or may not execute once or more int count; count = 0; /* Initialization action */ while (count < 5) { /* Loop test (condition) */ /* Loop body - action to repeat */ ++count; /* Loop increment */ }
77 Loop Structures The "do while" Loop Loop test is done last, at "bottom" of loop Always executes at least once int count; count = 0; /* Initialization action */ do { /* Loop body - action to repeat */ ++count; /* Loop increment */ } while (count < 5); /* Loop test (condition) */
78 Loop Structures The "for" Loop The "for" loop Contains initialization, loop test, and increment all in one place int count; for (count = 0; count < 5; ++count) { /* Loop body - action to repeat */ }
79 Different Loops for Different Purposes Counter controlled loop Loops a specific number of times as a counter increments Conditional loop Loops until a specific condition becomes true Sentinel controlled loop Processes data until a special value signals the end Processes data until a special value signals the end of data
80 Modifying Loop Execution The "break" statement break; This is an immediate exit from a loop Only used under unusual circumstances The "continue" statement Used to stop the current loop iteration Begins a new loop execution immediately continue;
81 Structured Code Design principle for code Entry at top of section Exit at bottom of section "Never" use the "goto" statement Very rare circumstances need "break" or "continue" in loop Avoid "spaghetti code" tangled, poorly written code
82 Functions Functions are easy to use; they allow complicated programs to be parcelled up into small blocks, each of which is easier to write, read, and maintain. We have already encountered the function main and made use of I/O and mathematical routines from the standard libraries. Now let's look at some other library functions, and how to write and use our own.
83 Calling a function The call to a function in C simply pyentails referencing its name with the appropriate arguments. The C compiler checks for compatibility between the arguments in the calling sequence and the definition of the function. Library functions are generally not available to us in source form. Argument type checking is accomplished through the use of header files (like stdio.h) which contain all the necessary information. For example, as we saw earlier, in order to use the standard mathematical library you must include math.h via the statement. #include <math.h>
84 1 84 Figure 3.6 Function sqrt as a Black Box
85 1 85 Figure 3.7 Square Root Program
86 1 86 Figure 3.7 Square Root Program (cont d)
87 Writing Your Own Functions 1 A function has the following layout: return type function name ( argument list if necessary ) {...local declarations......statements... return return value; }
88 1 88 Figure 3.23 Function scale
89 1 89 Figure 3.24 Testing Function scale
90 1 90 Figure 3.24 Testing Function scale (cont d)
91 Writing Your Own Functions 22 A function may simply perform a task without returning any value, in which case it has the following layout: void function name ( argument list if necessary ) {...local declarations......statements... }
92 1 92 Figure 3.12 Function draw_ circle
93 Figure 3.15 Flow of Control Between the main Function and a Function Subprogram 1 93
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 informationName: 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 informationEmbedded 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 informationInformatica 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 informationChapter 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 informationThe 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 informationPemrograman 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 informationPROGRAMMING IN C PROGRAMMING IN C CONTENT AT A GLANCE
PROGRAMMING IN C CONTENT AT A GLANCE 1 MODULE 1 Unit 1 : Basics of Programming Unit 2 : Fundamentals Unit 3 : C Operators MODULE 2 unit 1 : Input Output Statements unit 2 : Control Structures unit 3 :
More informationChapter 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 informationC++ Language Tutorial
cplusplus.com C++ Language Tutorial Written by: Juan Soulié Last revision: June, 2007 Available online at: http://www.cplusplus.com/doc/tutorial/ The online version is constantly revised and may contain
More informationKeywords 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 informationJavaScript: Control Statements I
1 7 JavaScript: Control Statements I 7.1 Introduction 2 The techniques you will learn here are applicable to most high-level languages, including JavaScript 1 7.2 Algorithms 3 Any computable problem can
More informationC PROGRAMMING FOR MATHEMATICAL COMPUTING
UNIVERSITY OF CALICUT SCHOOL OF DISTANCE EDUCATION BSc MATHEMATICS (2011 Admission Onwards) VI Semester Elective Course C PROGRAMMING FOR MATHEMATICAL COMPUTING QUESTION BANK Multiple Choice Questions
More informationIntroduction 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 informationKITES 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 informationC 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 informationC++ 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 informationComputer Programming Tutorial
Computer Programming Tutorial COMPUTER PROGRAMMING TUTORIAL by tutorialspoint.com tutorialspoint.com i ABOUT THE TUTORIAL Computer Prgramming Tutorial Computer programming is the act of writing computer
More informationTopics. 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 informationBachelors 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 informationMULTIPLE 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 informationMoving 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 informationSimple 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 informationTopics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives
Introduction to Programming and Algorithms Module 1 CS 146 Sam Houston State University Dr. Tim McGuire Module Objectives To understand: the necessity of programming, differences between hardware and software,
More informationThe 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 informationHow 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 informationSo 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 informationFirst 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 informationStorage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas
CS 110B - Rule Storage Classes Page 18-1 Attributes are distinctive features of a variable. Data type, int or double for example, is an attribute. Storage class is another attribute. There are four storage
More informationAbout 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 informationHandout 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 informationWe 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 informationJavaScript: Introduction to Scripting. 2008 Pearson Education, Inc. All rights reserved.
1 6 JavaScript: Introduction to Scripting 2 Comment is free, but facts are sacred. C. P. Scott The creditor hath a better memory than the debtor. James Howell When faced with a decision, I always ask,
More informationI PUC - Computer Science. Practical s Syllabus. Contents
I PUC - Computer Science Practical s Syllabus Contents Topics 1 Overview Of a Computer 1.1 Introduction 1.2 Functional Components of a computer (Working of each unit) 1.3 Evolution Of Computers 1.4 Generations
More informationIntroduction 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 informationPROG0101 Fundamentals of Programming PROG0101 FUNDAMENTALS OF PROGRAMMING. Chapter 3 Algorithms
PROG0101 FUNDAMENTALS OF PROGRAMMING Chapter 3 1 Introduction to A sequence of instructions. A procedure or formula for solving a problem. It was created mathematician, Mohammed ibn-musa al-khwarizmi.
More informationPROBLEM 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 informationLC-3 Assembly Language
LC-3 Assembly Language Programming and tips Textbook Chapter 7 CMPE12 Summer 2008 Assembly and Assembler Machine language - binary Assembly language - symbolic 0001110010000110 An assembler is a program
More informationC++ 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 informationThe C Programming Language
Chapter 1 The C Programming Language In this chapter we will learn how to write simple computer programs using the C programming language; perform basic mathematical calculations; manage data stored in
More informationMachine Architecture and Number Systems. Major Computer Components. Schematic Diagram of a Computer. The CPU. The Bus. Main Memory.
1 Topics Machine Architecture and Number Systems Major Computer Components Bits, Bytes, and Words The Decimal Number System The Binary Number System Converting from Decimal to Binary Major Computer Components
More informationIllustration 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 informationJAVA - QUICK GUIDE. Java SE is freely available from the link Download Java. So you download a version based on your operating system.
http://www.tutorialspoint.com/java/java_quick_guide.htm JAVA - QUICK GUIDE Copyright tutorialspoint.com What is Java? Java is: Object Oriented Platform independent: Simple Secure Architectural- neutral
More informationObjective-C Tutorial
Objective-C Tutorial OBJECTIVE-C TUTORIAL Simply Easy Learning by tutorialspoint.com tutorialspoint.com i ABOUT THE TUTORIAL Objective-c tutorial Objective-C is a general-purpose, object-oriented programming
More informationPhys4051: C Lecture 2 & 3. Comment Statements. C Data Types. Functions (Review) Comment Statements Variables & Operators Branching Instructions
Phys4051: C Lecture 2 & 3 Functions (Review) Comment Statements Variables & Operators Branching Instructions Comment Statements! Method 1: /* */! Method 2: // /* Single Line */ //Single Line /* This comment
More informationKeil C51 Cross Compiler
Keil C51 Cross Compiler ANSI C Compiler Generates fast compact code for the 8051 and it s derivatives Advantages of C over Assembler Do not need to know the microcontroller instruction set Register allocation
More informationOutline. hardware components programming environments. installing Python executing Python code. decimal and binary notations running Sage
Outline 1 Computer Architecture hardware components programming environments 2 Getting Started with Python installing Python executing Python code 3 Number Systems decimal and binary notations running
More informationCP 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 informationChapter 7 Assembly Language
Chapter 7 Assembly Language Human-Readable Machine Language Computers like ones and zeros 0001110010000110 Humans like symbols ADD R6,R2,R6 increment index reg. Assembler is a program that turns symbols
More informationObject 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 informationCS 106 Introduction to Computer Science I
CS 106 Introduction to Computer Science I 01 / 21 / 2014 Instructor: Michael Eckmann Today s Topics Introduction Homework assignment Review the syllabus Review the policies on academic dishonesty and improper
More informationMATLAB Programming. Problem 1: Sequential
Division of Engineering Fundamentals, Copyright 1999 by J.C. Malzahn Kampe 1 / 21 MATLAB Programming When we use the phrase computer solution, it should be understood that a computer will only follow directions;
More informationObject 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 informationExercise 4 Learning Python language fundamentals
Exercise 4 Learning Python language fundamentals Work with numbers Python can be used as a powerful calculator. Practicing math calculations in Python will help you not only perform these tasks, but also
More informationCS1020 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 informationProgramming the PIC18/ XC8 Using C- Coding Dr. Farahmand
Programming the PIC18/ XC8 Using C- Coding Dr. Farahmand Updated: 3/14/12 The C Compiler n The C18/XC8 compiler is a free program for students used for programing the PIC in C- Language. n Programming
More informationCourse Title: Software Development
Course Title: Software Development Unit: Customer Service Content Standard(s) and Depth of 1. Analyze customer software needs and system requirements to design an information technology-based project plan.
More informationWESTMORELAND COUNTY PUBLIC SCHOOLS 2011 2012 Integrated Instructional Pacing Guide and Checklist Computer Math
Textbook Correlation WESTMORELAND COUNTY PUBLIC SCHOOLS 2011 2012 Integrated Instructional Pacing Guide and Checklist Computer Math Following Directions Unit FIRST QUARTER AND SECOND QUARTER Logic Unit
More information5 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 informationFundamentals of Programming
Fundamentals of Programming Introduction to the C language Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa February 29, 2012 G. Lipari (Scuola Superiore Sant Anna) The C language
More informationQUIZ-II QUIZ-II. Chapter 5: Control Structures II (Repetition) Objectives. Objectives (cont d.) 20/11/2015. EEE 117 Computer Programming Fall-2015 1
QUIZ-II Write a program that mimics a calculator. The program should take as input two integers and the operation to be performed. It should then output the numbers, the operator, and the result. (For
More informationIntroduction 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 informationLecture 1 Introduction to Java
Programming Languages: Java Lecture 1 Introduction to Java Instructor: Omer Boyaci 1 2 Course Information History of Java Introduction First Program in Java: Printing a Line of Text Modifying Our First
More informationarrays 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 information9 Control Statements. 9.1 Introduction. 9.2 Objectives. 9.3 Statements
9 Control Statements 9.1 Introduction The normal flow of execution in a high level language is sequential, i.e., each statement is executed in the order of its appearance in the program. However, depending
More informationC++ Programming: From Problem Analysis to Program Design, Fifth Edition. Chapter 3: Input/Output
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 3: Input/Output Objectives In this chapter, you will: Learn what a stream is and examine input and output streams Explore
More informationMISRA-C:2012 Standards Model Summary for C / C++
MISRA-C:2012 Standards Model Summary for C / C++ The LDRA tool suite is developed and certified to BS EN ISO 9001:2000. This information is applicable to version 9.4.2 of the LDRA tool suite. It is correct
More informationASSEMBLY LANGUAGE PROGRAMMING (6800) (R. Horvath, Introduction to Microprocessors, Chapter 6)
ASSEMBLY LANGUAGE PROGRAMMING (6800) (R. Horvath, Introduction to Microprocessors, Chapter 6) 1 COMPUTER LANGUAGES In order for a computer to be able to execute a program, the program must first be present
More information2 ASCII TABLE (DOS) 3 ASCII TABLE (Window)
1 ASCII TABLE 2 ASCII TABLE (DOS) 3 ASCII TABLE (Window) 4 Keyboard Codes The Diagram below shows the codes that are returned when a key is pressed. For example, pressing a would return 0x61. If it is
More informationProgramming Microcontrollers in C
Programming Microcontrollers in C Second Edition Ted Van Sickle A Volume in the EMBEDDED TECHNOLOGY TM Series Eagle Rock, Virginia www.llh-publishing.com Programming Microcontrollers in C 2001 by LLH Technology
More informationStacks. Linear data structures
Stacks Linear data structures Collection of components that can be arranged as a straight line Data structure grows or shrinks as we add or remove objects ADTs provide an abstract layer for various operations
More informationCS 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 informationC Compiler Targeting the Java Virtual Machine
C Compiler Targeting the Java Virtual Machine Jack Pien Senior Honors Thesis (Advisor: Javed A. Aslam) Dartmouth College Computer Science Technical Report PCS-TR98-334 May 30, 1998 Abstract One of the
More informationChapter 2 Introduction to Java programming
Chapter 2 Introduction to Java programming 1 Keywords boolean if interface class true char else package volatile false byte final switch while throws float private case return native void protected break
More information2 SYSTEM DESCRIPTION TECHNIQUES
2 SYSTEM DESCRIPTION TECHNIQUES 2.1 INTRODUCTION Graphical representation of any process is always better and more meaningful than its representation in words. Moreover, it is very difficult to arrange
More informationNumbering Systems. InThisAppendix...
G InThisAppendix... Introduction Binary Numbering System Hexadecimal Numbering System Octal Numbering System Binary Coded Decimal (BCD) Numbering System Real (Floating Point) Numbering System BCD/Binary/Decimal/Hex/Octal
More informationC / 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 informationUIL 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 informationVariables, Constants, and Data Types
Variables, Constants, and Data Types Primitive Data Types Variables, Initialization, and Assignment Constants Characters Strings Reading for this class: L&L, 2.1-2.3, App C 1 Primitive Data There are eight
More informationPART-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 informationExample of a Java program
Example of a Java program class SomeNumbers static int square (int x) return x*x; public static void main (String[] args) int n=20; if (args.length > 0) // change default n = Integer.parseInt(args[0]);
More informationComputer Science 217
Computer Science 217 Midterm Exam Fall 2009 October 29, 2009 Name: ID: Instructions: Neatly print your name and ID number in the spaces provided above. Pick the best answer for each multiple choice question.
More informationASCII 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 information1 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 informationProgramming in Java. 2013 Course Technology, a part of Cengage Learning.
C7934_chapter_java.qxd 12/20/11 12:31 PM Page 1 Programming in Java Online module to accompany Invitation to Computer Science, 6th Edition ISBN-10: 1133190820; ISBN-13: 9781133190820 (Cengage Learning,
More informationAn Introduction to the WEB Style of Literate Programming
An Introduction to the WEB Style of Literate Programming Literate Programming by Bart Childs One of the greatest needs in computing is the reduction of the cost of maintenance of codes. Maintenance programmers
More informationChapter 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 informationOutline. Conditional Statements. Logical Data in C. Logical Expressions. Relational Examples. Relational Operators
Conditional Statements For computer to make decisions, must be able to test CONDITIONS IF it is raining THEN I will not go outside IF Count is not zero THEN the Average is Sum divided by Count Conditions
More informationwhat operations can it perform? how does it perform them? on what kind of data? where are instructions and data stored?
Inside the CPU how does the CPU work? what operations can it perform? how does it perform them? on what kind of data? where are instructions and data stored? some short, boring programs to illustrate the
More information1 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 informationJava 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 informationInstall Java Development Kit (JDK) 1.8 http://www.oracle.com/technetwork/java/javase/downloads/index.html
CS 259: Data Structures with Java Hello World with the IntelliJ IDE Instructor: Joel Castellanos e-mail: joel.unm.edu Web: http://cs.unm.edu/~joel/ Office: Farris Engineering Center 319 8/19/2015 Install
More informationSECTION C [short essay] [Not to exceed 120 words, Answer any SIX questions. Each question carries FOUR marks] 6 x 4=24 marks
UNIVERSITY OF KERALA First Degree Programme in Computer Applications Model Question Paper Semester I Course Code- CP 1121 Introduction to Computer Science TIME : 3 hrs Maximum Mark: 80 SECTION A [Very
More informationVisual Logic Instructions and Assignments
Visual Logic Instructions and Assignments Visual Logic can be installed from the CD that accompanies our textbook. It is a nifty tool for creating program flowcharts, but that is only half of the story.
More informationHigh-Level Programming Languages. Nell Dale & John Lewis (adaptation by Michael Goldwasser)
High-Level Programming Languages Nell Dale & John Lewis (adaptation by Michael Goldwasser) Low-Level Languages What are disadvantages of low-level languages? (e.g., machine code or assembly code) Programming
More informationMICROPROCESSOR AND MICROCOMPUTER BASICS
Introduction MICROPROCESSOR AND MICROCOMPUTER BASICS At present there are many types and sizes of computers available. These computers are designed and constructed based on digital and Integrated Circuit
More informationSemantic 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 informationBoolean Expressions, Conditions, Loops, and Enumerations. Precedence Rules (from highest to lowest priority)
Boolean Expressions, Conditions, Loops, and Enumerations Relational Operators == // true if two values are equivalent!= // true if two values are not equivalent < // true if left value is less than the
More information