CMSC 106 Introduction to C Programming

Size: px
Start display at page:

Download "CMSC 106 Introduction to C Programming"

Transcription

1 CMSC 106 Introduction to C Programming Math Library, Escape Sequences, Conditionals CMSC Slides developed by Jan Plane with some modifications by Nelson Padua-Perez

2 Additional Operators Increment and Decrement ++ and -- Unary operators Prefix & postfix Example: increment_decrement.c 2

3 Math Library Functions #include <math.h> -lm option when compiling on some systems gcc mycode.c -lm Must be careful to watch the types efs/math.h.html Example: math_library.c 3

4 More Formatted Output What we ve done so far %d integer in as much space as needed %.2f float in as much space as needed with two decimal places also shown Other Variations %nd where n is any integer leaves extra space before the number if there is any %-nd where n is any integer leaves extra space on the right %n.xf where n and x are any integers n indicates total width and x indicates decimal places Example: formatted_output.c 4

5 More escape sequences \n new line \t advances cursor to next tab stop \r carriage return \b backspace \a beep \" " \\ \ %% % Examples: printf( Jan\n\tPlane\n ); printf("\"\\n\""); output: Jan "\n Plane 5

6 boolean statements Does not exist as a type in C Many people use symbolic constants to define them so they look like they exist In C 0 is false any other value is true

7 Submit Server What is release testing? How can we release test a project? How many chances you have to release test your project?

8 Input/Output Redirection What is input/output redirection? Example: input_output_redirection.c

9 Miscellaneous Using Unix script to keep track of session Start session script todayslecture End session exit Let s go over an example Make sure you alias gcc to the appropriate options See gcc_aliases_info.txt (in public Info folder) Keep your environment organized You can create directories and use mv to organize your files To remove files/folders use rm

10 Important Operators Relational Operators Equality:x == y Inequality: x!= y Less than: x < y Greater than: x > y Less than or equal to: x <= y Greater than or equal: x >= y Logical Operators And: a && b Or: a b Not:!a

11 Operator Precedence Operator Associativity!, unary -, ++, -- right to left *, /, % left to right +, - left to right <, <=, >, >= left to right ==,!= left to right && left to right left to right =, +=, -=, *=, /= right to left * note the unary increment and decrement operators have high precedence even when used as postfix but the time of operation doesn t get used until after

12 Conditions and Expressions 0 is considered false and any other value is considered true equality or relational operators (<, <=, >, >=, ==,!=) produces result 0 or 1

13 The Logical Operators && (and) (binary operator) (or) (binary operator)! (not) (unary, prefix) Produce values of 0 and 1 Truth Tables are a good way to show what they mean

14 The "if" Statement Conditional execution of the statement if (condition) statement; One statement Notice: no semicolon after (condition) Indentation not needed for compiler Needed for people Process: Condition is tested Execution continues based on the truth value of the condition If true subsidiary statement is executed If false subsidiary statement is skipped In both cases execution continues with next statement (after entire if statement)

15 The "if" Statement #include <stdio.h> /* reads two ints praises for following directions */ int main() { int x, y; } printf( Type the same positive value twice: ); scanf("%d %d", &x, &y); if (x == y && x > 0) printf( Good Job\n ); printf( We are done here\n ); return 0; Example: cond1.c Either praises you for following directions or just goes on (no criticism).

16 Beware of the assignment operator used in an expression #include <stdio.h> /* reads two ints praises for following directions */ int main() { int x, y; } printf( Type the same positive value twice: ); scanf("%d %d", &x, &y); if (x = y && x > 0) printf( Good Job\n ); printf( We are done here\n ); return 0; Example: cond2.c Read carefully does it really do what it says?

17 The if/else Statement The if/else contains two subsidiary statements; one is always executed if (condition) statement1; else statement2; Still considered one statement but it has 2 subsidiary statements Process: Condition is tested Execution continues based on the truth value of the condition If true subsidiary statement 1 is executed If false subsidiary statement 2 is executed In both cases execution continues with next statement (after entire if statement) Example: cond3.c

18 Blocks/Compound Statements Any number of statements can be grouped inside braces { } if (num1 >= num2) { printf("%d\n", num1); num3= num1 * num1; } Semicolon not needed after a compound statement

19 Nested if statements int month, day; scanf("%d", &day); if (day > 31) if (day <= 60) printf("february\n"); int month, day; scanf("%d", &day); if (day <= 31) month= 1; else if (day <= 60) month= 2;

20 Can be inside of a Block or not int month, day; scanf("%d", &day); if (day <= 90) { printf( first third of year\n ); if (day <= 60) { if (day <= 31) { month= 1; printf( it s January\n ); } else { month=2; printf( Feb\n ); } } else month = 3; }

21 Dangling Else s To which if does this one else belong? if (x < 10) if (y > 10) printf("a\n"); else printf("b\n"); Example: dangling_else.c

22 The Conditional Expression C's only ternary operator condition? expression1 : expression2 If condition is true expression1's value is calculated and Becomes the whole conditional expression's value Otherwise its value is expression2's value Example: ternary_op.c

23 Short-circuit Evaluation of Logical Operators Once the value of an expression can be determined (C stops the evaluation of that expression) With && - if the left operand is false, the whole statement must be false With - if the left operand is true, the whole statement must be true Example: short_circuiting*.c

24 Common Mistakes Forgetting that relational operators are only binary operators Assuming the && or can do more than it can Assuming the! has lower precedence than it does

25 Cascaded if Statement If you have cases to handle, use a cascaded if statement It is not a a new statement; just a different way to write a nested loop Example: cascaded_if.c

26 sizeof and Limits on Types ANSI only specifies minimum amount of space for a specified type not an exact sizeof() operator returns the number of bytes when passed a type or a variable as the operand (in parentheses) grace.umd.edu: it returns an unsigned int on one system and a long int on the other casting of types needed because of inconsistency printf( %d,(int)sizeof(float)); Cast does not modify the type of the operand it just returns a value of the type indicated Example: types_sizes.c 26

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

Outline. Conditional Statements. Logical Data in C. Logical Expressions. Relational Examples. Relational Operators

Outline. 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 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

Selection Statements

Selection Statements Chapter 5 Selection Statements 1 Statements So far, we ve used return statements and expression ess statements. e ts. Most of C s remaining statements fall into three categories: Selection statements:

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

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

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

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

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

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

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

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

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

Lecture 1 Introduction to Java

Lecture 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 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

JavaScript: Control Statements I

JavaScript: 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 information

C++ Language Tutorial

C++ 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 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

Objective-C Tutorial

Objective-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 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

Decision Logic: if, if else, switch, Boolean conditions and variables

Decision Logic: if, if else, switch, Boolean conditions and variables CS 1044 roject 3 Fall 2009 Decision Logic: if, if else, switch, Boolean conditions and variables This programming assignment uses many of the ideas presented in sections 3 through 5 of the Dale/Weems text

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

Lecture 2 Notes: Flow of Control

Lecture 2 Notes: Flow of Control 6.096 Introduction to C++ January, 2011 Massachusetts Institute of Technology John Marrero Lecture 2 Notes: Flow of Control 1 Motivation Normally, a program executes statements from first to last. The

More information

Computer Programming Tutorial

Computer 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 information

C PROGRAMMING FOR MATHEMATICAL COMPUTING

C 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 information

Chapter 5. Selection 5-1

Chapter 5. Selection 5-1 Chapter 5 Selection 5-1 Selection (Decision) The second control logic structure is selection: Selection Choosing between two or more alternative actions. Selection statements alter the sequential flow

More information

Chapter 3 Operators and Control Flow

Chapter 3 Operators and Control Flow Chapter 3 Operators and Control Flow I n this chapter, you will learn about operators, control flow statements, and the C# preprocessor. Operators provide syntax for performing different calculations or

More information

PROGRAMMING IN C PROGRAMMING IN C CONTENT AT A GLANCE

PROGRAMMING 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 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

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

Example of a Java program

Example 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 information

Two-way selection. Branching and Looping

Two-way selection. Branching and Looping Control Structures: are those statements that decide the order in which individual statements or instructions of a program are executed or evaluated. Control Structures are broadly classified into: 1.

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

The C Programming Language

The 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 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

C Language Tutorial. Version 0.042 March, 1999

C Language Tutorial. Version 0.042 March, 1999 C Language Tutorial Version 0.042 March, 1999 Original MS-DOS tutorial by Gordon Dodrill, Coronado Enterprises. Moved to Applix by Tim Ward Typed by Karen Ward C programs converted by Tim Ward and Mark

More information

PL / SQL Basics. Chapter 3

PL / SQL Basics. Chapter 3 PL / SQL Basics Chapter 3 PL / SQL Basics PL / SQL block Lexical units Variable declarations PL / SQL types Expressions and operators PL / SQL control structures PL / SQL style guide 2 PL / SQL Block Basic

More information

Senem Kumova Metin & Ilker Korkmaz 1

Senem Kumova Metin & Ilker Korkmaz 1 Senem Kumova Metin & Ilker Korkmaz 1 A loop is a block of code that can be performed repeatedly. A loop is controlled by a condition that is checked each time through the loop. C supports two categories

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

TIP: To access the WinRunner help system at any time, press the F1 key.

TIP: To access the WinRunner help system at any time, press the F1 key. CHAPTER 11 TEST SCRIPT LANGUAGE We will now look at the TSL language. You have already been exposed to this language at various points of this book. All the recorded scripts that WinRunner creates when

More information

Windows PowerShell Essentials

Windows PowerShell Essentials Windows PowerShell Essentials Windows PowerShell Essentials Edition 1.0. This ebook is provided for personal use only. Unauthorized use, reproduction and/or distribution strictly prohibited. All rights

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

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

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

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 8 Selection 8-1

Chapter 8 Selection 8-1 Chapter 8 Selection 8-1 Selection (Decision) The second control logic structure is selection: Selection Choosing between two or more alternative actions. Selection statements alter the sequential flow

More information

Fundamentals of Programming

Fundamentals 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 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

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

C Programming Tutorial

C Programming Tutorial C Programming Tutorial C PROGRAMMING TUTORIAL Simply Easy Learning by tutorialspoint.com tutorialspoint.com i C O P Y R I G H T & D I S C L A I M E R N O T I C E All the content and graphics on this tutorial

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

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

CS 106 Introduction to Computer Science I

CS 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 information

Perl in a nutshell. First CGI Script and Perl. Creating a Link to a Script. print Function. Parsing Data 4/27/2009. First CGI Script and Perl

Perl in a nutshell. First CGI Script and Perl. Creating a Link to a Script. print Function. Parsing Data 4/27/2009. First CGI Script and Perl First CGI Script and Perl Perl in a nutshell Prof. Rasley shebang line tells the operating system where the Perl interpreter is located necessary on UNIX comment line ignored by the Perl interpreter End

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

Course Title: Software Development

Course 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 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

Conditionals (with solutions)

Conditionals (with solutions) Conditionals (with solutions) For exercises 1 to 27, indicate the output that will be produced. Assume the following declarations: final int MAX = 25, LIMIT = 100; int num1 = 12, num2 = 25, num3 = 87;

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

Programming Microcontrollers in C

Programming 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 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

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

C++ Essentials. Sharam Hekmat PragSoft Corporation www.pragsoft.com

C++ Essentials. Sharam Hekmat PragSoft Corporation www.pragsoft.com C++ Essentials Sharam Hekmat PragSoft Corporation www.pragsoft.com Contents Contents Preface 1. Preliminaries 1 A Simple C++ Program 2 Compiling a Simple C++ Program 3 How C++ Compilation Works 4 Variables

More information

Boolean Expressions & the if Statement

Boolean Expressions & the if Statement Midterm Results Boolean Expressions & the if Statement September 24, 2007 Average: 91.6 Median: 94 Standard Deviation: 18.80 Maximum: 129 (out of 130) ComS 207: Programming I (in Java) Iowa State University,

More information

JAVA - QUICK GUIDE. Java SE is freely available from the link Download Java. So you download a version based on your operating system.

JAVA - 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 information

General Software Development Standards and Guidelines Version 3.5

General Software Development Standards and Guidelines Version 3.5 NATIONAL WEATHER SERVICE OFFICE of HYDROLOGIC DEVELOPMENT Science Infusion Software Engineering Process Group (SISEPG) General Software Development Standards and Guidelines 7/30/2007 Revision History Date

More information

Computer Programming In QBasic

Computer Programming In QBasic Computer Programming In QBasic Name: Class ID. Computer# Introduction You've probably used computers to play games, and to write reports for school. It's a lot more fun to create your own games to play

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

Variables, Constants, and Data Types

Variables, 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 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

Statements and Control Flow

Statements and Control Flow Contents 1. Introduction 2. Types and Variables 3. Statements and Control Flow 4. Reading Input 5. Classes and Objects 6. Arrays 7. Methods 8. Scope and Lifetime 9. Utility classes 10. Introduction to

More information

AppendixA1A1. Java Language Coding Guidelines. A1.1 Introduction

AppendixA1A1. Java Language Coding Guidelines. A1.1 Introduction AppendixA1A1 Java Language Coding Guidelines A1.1 Introduction This coding style guide is a simplified version of one that has been used with good success both in industrial practice and for college courses.

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

QUIZ-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 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 information

Python Programming: An Introduction To Computer Science

Python Programming: An Introduction To Computer Science Python Programming: An Introduction To Computer Science Chapter 8 Booleans and Control Structures Python Programming, 2/e 1 Objectives æ To understand the concept of Boolean expressions and the bool data

More information

7th Marathon of Parallel Programming WSCAD-SSC/SBAC-PAD-2012

7th Marathon of Parallel Programming WSCAD-SSC/SBAC-PAD-2012 7th Marathon of Parallel Programming WSCAD-SSC/SBAC-PAD-2012 October 17 th, 2012. Rules For all problems, read carefully the input and output session. For all problems, a sequential implementation is given,

More information

The first program: Little Crab

The first program: Little Crab CHAPTER 2 The first program: Little Crab topics: concepts: writing code: movement, turning, reacting to the screen edges source code, method call, parameter, sequence, if-statement In the previous chapter,

More information

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

CSC 221: Computer Programming I. Fall 2011

CSC 221: Computer Programming I. Fall 2011 CSC 221: Computer Programming I Fall 2011 Python control statements operator precedence importing modules random, math conditional execution: if, if-else, if-elif-else counter-driven repetition: for conditional

More information

Exercise 4 Learning Python language fundamentals

Exercise 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 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

X86-64 Architecture Guide

X86-64 Architecture Guide X86-64 Architecture Guide For the code-generation project, we shall expose you to a simplified version of the x86-64 platform. Example Consider the following Decaf program: class Program { int foo(int

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

6. Control Structures

6. Control Structures - 35 - Control Structures: 6. Control Structures A program is usually not limited to a linear sequence of instructions. During its process it may bifurcate, repeat code or take decisions. For that purpose,

More information

How To Write A Programming Program

How To Write A Programming Program 1 Preface... 6 Preface to the first edition...8 Chapter 1 - A Tutorial Introduction...9 1.1 Getting Started...9 1.2 Variables and Arithmetic Expressions...11 1.3 The for statement...15 1.4 Symbolic Constants...17

More information

2 The first program: Little Crab

2 The first program: Little Crab 2 The first program: Little Crab topics: concepts: writing code: movement, turning, reacting to the screen edges source code, method call, parameter, sequence, if statement In the previous chapter, we

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

Writing Control Structures

Writing Control Structures Writing Control Structures Copyright 2006, Oracle. All rights reserved. Oracle Database 10g: PL/SQL Fundamentals 5-1 Objectives After completing this lesson, you should be able to do the following: Identify

More information

JavaScript: Introduction to Scripting. 2008 Pearson Education, Inc. All rights reserved.

JavaScript: 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 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

Chapter 1: Computer Systems

Chapter 1: Computer Systems Presentation slides for Java Software Solutions Foundations of Program Design Second Edition by John Lewis and William Loftus Part I (chapters 1 5) Prepared for Java Programming 90.301 by Marjan Trutschl

More information

if and if-else: Part 1

if and if-else: Part 1 if and if-else: Part 1 Objectives Write if statements (including blocks) Write if-else statements (including blocks) Write nested if-else statements We will now talk about writing statements that make

More information

Programming in C an introduction

Programming in C an introduction Programming in C an introduction PRC for E Maarten Pennings Version 0.5 (2007-12-31) 0 0 Preface This book explains the C programming language. It assumes no programming knowledge. The reader is supposed

More information

Boolean Expressions, Conditions, Loops, and Enumerations. Precedence Rules (from highest to lowest priority)

Boolean 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

1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++

1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++ Answer the following 1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++ 2) Which data structure is needed to convert infix notations to postfix notations? Stack 3) The

More information

Command Scripts. 13.1 Running scripts: include and commands

Command Scripts. 13.1 Running scripts: include and commands 13 Command Scripts You will probably find that your most intensive use of AMPL s command environment occurs during the initial development of a model, when the results are unfamiliar and changes are frequent.

More information

Conditions & Boolean Expressions

Conditions & Boolean Expressions Conditions & Boolean Expressions 1 In C++, in order to ask a question, a program makes an assertion which is evaluated to either true (nonzero) or false (zero) by the computer at run time. Example: In

More information

Programming Languages CIS 443

Programming Languages CIS 443 Course Objectives Programming Languages CIS 443 0.1 Lexical analysis Syntax Semantics Functional programming Variable lifetime and scoping Parameter passing Object-oriented programming Continuations Exception

More information

Secrets of printf. 1 Background. 2 Simple Printing. Professor Don Colton. Brigham Young University Hawaii. 2.1 Naturally Special Characters

Secrets of printf. 1 Background. 2 Simple Printing. Professor Don Colton. Brigham Young University Hawaii. 2.1 Naturally Special Characters Secrets of Professor Don Colton Brigham Young University Hawaii is the C language function to do formatted printing. The same function is also available in PERL. This paper explains how works, and how

More information