# Phys4051: C Lecture 2 & 3. Comment Statements. C Data Types. Functions (Review) Comment Statements Variables & Operators Branching Instructions

Save this PDF as:

Size: px
Start display at page:

Download "Phys4051: C Lecture 2 & 3. Comment Statements. C Data Types. Functions (Review) Comment Statements Variables & Operators Branching Instructions"

## Transcription

1 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 spans more than one line. */ // This comment // spans more than // one line. int x; //variable x 2 C Data Types! No Return Value: (For functions & pointers only!)! Integers:! Real (floating point):! void! char! short! int! long! float! double 3 1

2 Data Types: Signed / Unsigned! All integer data type declarations can be signed (default) or unsigned.! Example:! unsigned int ival = 134;! signed int sval = -107; 4 Global / Local Variables! All variables declared outside of a function are GLOBAL.! Global variables have global scope, i.e., they are seen in ALL the functions.! All variables declared within a function are LOCAL to that function.! Local variables have local scope. They "exist" only within the function that declares them. 5 Variable Declarations! Position in Program: Global vs. Local Always declare variables before any statements or before main! 6 2

3 Variable Initialization! Global Variables:! Always initialized to 0! Local Variables:! Never initialized! Random 7 Variable Declaration & Initialization! Example 1a:! Example 1b:! short x; short y; short z;! short x = 3, y =3, z; x = 3; y = 4; 8 C-Operators -Mathematical -Relational - Assignment -Logical -Bitwise 3

4 C-Operators! Are always executed:! 1: Left to right! 2: By order of precedent 10 Mathematical C-Operators! By order of precedence:! * Multiplication! / Division! % Remainder: ex 13%4 = 1! + Addition! - Subtraction 11 Mathematical C-Operators:! Accuracy:! When applying an operator to variables having different levels of accuracy, then the calculation is carried out using the level of accuracy as specified by the variable with the higher level of accuracy.! Example: 12 4

5 Mathematical C-Operators: Accuracy Example short k, m = 2, n = 3; float a, b = 2.0, c = 3.0; k = m / n; k = b / n; a = m / n; a = 1.0 * m / n; a = (float) m / n; //type casting a = b / c; k =? k =? a =? a =? a =? a =? 13 Mathematical C-Operators: Shortcut Notations Equivalent Notations: x = x + 1; x = x - 1; x++; x--; ++x; --x; a = a ; a = a ; a = a * 3.14; a = a / 3.14; a + = 3.14; a - = 3.14; a * = 3.14; a / = 3.14; 14 C-Operators: Shortcut Notations Example! Example 1:! Example 2 int y, x = 4051; y = ++x; printf("%d", y); int y, x = 4051; y = x++; printf("%d", y);! Output:! Output: 15 5

6 Branching Instructions: Simple if-statement! Example1:! if ( logic condition ) statement(s);! if ( x > 1 ) x = 0; printf( Hello ); 16 Logic Condition! TRUE: Anything, except 0 or FALSE! FALSE: Only 0 or FALSE! Example: if( 3 ) printf( always true );! Example: if( 0 ) printf( never true ); 17 if-else Statement! if( logic condition ) //executed only if logic statement(s); //condition is TRUE else //executed only if logic statement(s); //condition is FALSE 18 6

7 if-statement Shortcut Notation (1)! If the if-statement contains only ONE statement, braces can be omitted: if( x ) printf( TRUE ); else printf( FALSE ) Equivalent program segment: if( x ) printf( TRUE); else printf( FALSE); 19 if-statement Shortcut Notation (1) WARNING!!! if( x ) printf( TRUE ); else printf( FALSE ); printf( AGAIN ); printf( DONE ) if( x ) printf( TRUE ); else printf( FALSE ); printf( AGAIN ); printf( DONE ); 20 Relational Operators (1) < <= > >= Less Than Less Than and Equal Greater Than Greater Than and Equal ==!= Equal Not Equal 21 7

8 Relational Operators (2) WARNING: Equal Operator! Example 1:! Example 2: short x = 5; if( x = 3 ) printf( x is 3 ); Output: short x = 5; if( x == 3) printf( x is 3 ); Output: 22 Relational Operators (3) The Not (!) Operator What is the difference between the following two program segments? if(!x ) if( x == 0 ) 23 Logic Operators: AND & OR (1) The following operators act on the entire variable or expression as a whole and return either TRUE (1) or FALSE (0) && AND OR (shift \ key) 24 8

9 Logic Operators: (Bytewise) AND & OR (2)! The AND and OR operators are often used to link relational operators.! Example: How do you write 3 < x < 10 in C? 25 Logic Operators: Bitwise Operators (1) << >> ~ & ^ Left Shift Right Shift Bitwise NOT Bitwise AND Bitwise XOR Bitwise OR! Bitwise operators operate on a variable or expression bit by bit. 26 Bytewise and Bitwise Operators (2)! Example 1: Bytewise short a = 5, b = 10, y; y = a && b;! Example 2: Bitwise short a = 5, b = 10, y; y = a & b; y =??? y =??? 27 9

10 Logic Operators: Bitwise Operators (3)! Bitwise operators are often used in hardware control applications! Example 1: Check one specific bit in a byte (BIT MASKING)! Example 2: Toggle a specific bit in a byte 28 10

11 Typical C-Function Syntax Function Declaration double Thdeg( float x, float y) ; Function Header double Thdeg( float x, float y) Local float fthetadeg, fthetarad ; Variable float fpi = ; Declarations double ftan ; Statements ftan = y / x ; and fthetarad = atan ( ftan ) ; Function Calls fthetadeg = ftheta * 180.0/fPi ; return ( fthetadeg );

12 Data Type Range Bytes Signed Declaration Range Unsigned Declaration 1 char -128 to 127 unsigned char 2 short to (or: int) long to float ±3.4 E±38 8 double ±1.7 E±308 unsigned short (unsigned int) Range 0 to to to

13 Program Global & Local Variables #include <ansi_c.h> void F1( short x); void F2( short x); short s1; main() short sm1; short sm2 = 123; //Non-intialized values printf("part 1: Non-Initialized Variables\n"); printf("s1: %d\n", s1); printf("sm1: %d\n\n", sm1); printf("part 2: Passing a Variable to a Function\n"); printf("sm2: %d\n", sm2); F1( sm2 ); //passing a variable by value printf("sm2: %d\n\n", sm2); printf("global vs. Local Variables\n"); F2( sm2 ); //global vs. local variables printf("sm2: %d\n", sm2); printf("s1: %d\n\n", s1); void F1( short x) printf("before: x: %d\t", x); x = 888; printf("after: x: %d\n", x); void F2( short x) short sm2 = -111; s1 = -1234;

14 Output: Part 1: Non-Initialized Variables s1: sm1: Part 2: Passing a Variable to a Function sm2: before: x: after: x: sm2: Global vs. Local Variables sm2: s1:

15 1) ANSI-C / No GUI //Program MyMaxNoGui #include <ansi_c.h> float MyMax(float x, float y); main() float u = 123.0, v = ; float res; res = MyMax( u, v); printf("maximum is: %f\n", res); float MyMax(float x, float y) float max; if( x > y) max = x; else max = y; return max;

16 2) LabWindows / With GUI 2a) LabWindows Generated Code: #include <cvirte.h> #include <userint.h> #include "MyMaxGui.h" static int panelhandle; int main (int argc, char *argv[]) if (InitCVIRTE (0, argv, 0) == 0) return -1; /* out of memory */ if ((panelhandle = LoadPanel (0, "MyMaxGui.uir", PANEL)) < 0) return -1; DisplayPanel (panelhandle); RunUserInterface (); return 0; int CVICALLBACK Quit (int panel, int control, int event, void *callbackdata, int eventdata1, int eventdata2) switch (event) case EVENT_COMMIT: QuitUserInterface (0); break; return 0; int CVICALLBACK CalcMax (int panel, int control, int event, void *callbackdata, int eventdata1, int eventdata2) switch (event) case EVENT_COMMIT: return 0; break;

17 2b) Code for MyMax function added (in Bold): #include <ansi_c.h> #include <cvirte.h> #include <userint.h> #include "MyMaxGui.h" static int panelhandle; float MyMax(float x, float y); int main (int argc, char *argv[]) if (InitCVIRTE (0, argv, 0) == 0) return -1; /* out of memory */ if ((panelhandle = LoadPanel (0, "MyMaxGui.uir", PANEL)) < 0) return -1; DisplayPanel (panelhandle); RunUserInterface (); return 0; int CVICALLBACK Quit (int panel, int control, int event, void *callbackdata, int eventdata1, int eventdata2) switch (event) case EVENT_COMMIT: QuitUserInterface (0); break; return 0; int CVICALLBACK CalcMax (int panel, int control, int event, void *callbackdata, int eventdata1, int eventdata2) float u = 123.0, v = ; float res; switch (event) case EVENT_COMMIT: res = MyMax( u, v); printf("maximum is: %f\n", res); return 0; break;

18 float MyMax(float x, float y) float max; if( x > y) max = x; else max = y; return max; 2c) Code Added to Read Input and to Display the Result: (Changes from previous version are shown in bold) #include <ansi_c.h> #include <cvirte.h> /* Needed if linking in external compiler; harmless otherwise */ #include <userint.h> #include "MyMaxGui.h" static int panelhandle; float MyMax(float x, float y); int main (int argc, char *argv[]) if (InitCVIRTE (0, argv, 0) == 0) /* Needed if linking in external compiler; harmless otherwise */ return -1; /* out of memory */ if ((panelhandle = LoadPanel (0, "MyMaxGui.uir", PANEL)) < 0) return -1; DisplayPanel (panelhandle); RunUserInterface ();

19 return 0; int CVICALLBACK Quit (int panel, int control, int event, void *callbackdata, int eventdata1, int eventdata2) switch (event) case EVENT_COMMIT: QuitUserInterface (0); break; return 0; int CVICALLBACK CalcMax (int panel, int control, int event, void *callbackdata, int eventdata1, int eventdata2) float u, v; float res; switch (event) case EVENT_COMMIT: GetCtrlVal (panelhandle, PANEL_XINPUT, &u); GetCtrlVal (panelhandle, PANEL_XINPUT, &v); res = MyMax( u, v); return 0; SetCtrlVal (panelhandle, PANEL_RESULT, res); break; float MyMax(float x, float y) float max; if( x > y) max = x; else max = y; return max;

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

### Punctuation in C. Identifiers and Expressions. Identifiers. Variables. Keywords. Identifier Examples

Identifiers and Expressions CSE 130: Introduction to C Programming Spring 2005 Punctuation in C Statements are terminated with a ; Groups of statements are enclosed by curly braces: { and } Commas separate

### Branching. We ll continue to look at the basics of writing C++ programs including. Overview

Branching Overview We ll continue to look at the basics of writing C++ programs including Boolean Expressions (need to know this before we can using branching and looping!) Branching J.S. Bradbury CSCI

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

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

### Introduction to Programming

Introduction to Programming SS 2012 Adrian Kacso, Univ. Siegen adriana.dkacsoa@duni-siegena.de Tel.: 0271/740-3966, Office: H-B 8406 Stand: April 25, 2012 Betriebssysteme / verteilte Systeme Introduction

### 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)

### Dept. of CSE, IIT KGP

Programming in C: Basics CS10001: Programming & Data Structures Pallab Dasgupta Professor, Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur Types of variable We must declare the

### Keil 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

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

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

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

### Basic C Syntax. Comp-206 : Introduction to Software Systems Lecture 10. Alexandre Denault Computer Science McGill University Fall 2006

Basic C Syntax Comp-206 : Introduction to Software Systems Lecture 10 Alexandre Denault Computer Science McGill University Fall 2006 Next Week I'm away for the week. I'll still check my mails though. No

### 198:211 Computer Architecture

198:211 Computer Architecture Topics: Lecture 8 (W5) Fall 2012 Data representation 2.1 and 2.2 of the book Floating point 2.4 of the book 1 Computer Architecture What do computers do? Manipulate stored

### 1. Constants. 2. Variables. 3. Reserved words or key words. 4. Constants. Character set in C

Character set in C We should use only the following characters in writing a C program. These characters can be combined to create C words. Alphabet: A, B, C, D.. Z, a, b, c, d..z Numeric digits: 0, 1,

### Introduction to C Programming S Y STEMS

Introduction to C Programming CS 40: INTRODUCTION TO U NIX A ND L I NUX O P E R AT ING S Y STEMS Objectives Introduce C programming, including what it is and what it contains, which includes: Command line

### INDEX. C programming Page 1 of 10. 5) Function. 1) Introduction to C Programming

INDEX 1) Introduction to C Programming a. What is C? b. Getting started with C 2) Data Types, Variables, Constants a. Constants, Variables and Keywords b. Types of Variables c. C Keyword d. Types of C

### Common C Errors. Compiled by: Leela Kamalesh Yadlapalli

Common C Errors Compiled by: Leela Kamalesh Yadlapalli This document shows some of the common errors and warnings that you may encounter during this class. Always remember to use the Wall option if you

### Programming for MSc Part I

Herbert Martin Dietze University of Buckingham herbert@the-little-red-haired-girl.org July 24, 2001 Abstract The course introduces the C programming language and fundamental software development techniques.

### C Programming Dr. Hasan Demirel

C How to Program, H. M. Deitel and P. J. Deitel, Prentice Hall, 5 th edition (3 rd edition or above is also OK). Introduction to C Programming Dr. Hasan Demirel Programming Languages There are three types

### Programming Language: Syntax. Introduction to C Language Overview, variables, Operators, Statements

Programming Language: Syntax Introduction to C Language Overview, variables, Operators, Statements Based on slides McGraw-Hill Additional material 2004/2005 Lewis/Martin Modified by Diana Palsetia Syntax

### Programing the Microprocessor in C Microprocessor System Design and Interfacing ECE 362

PURDUE UNIVERSITY Programing the Microprocessor in C Microprocessor System Design and Interfacing ECE 362 Course Staff 1/31/2012 1 Introduction This tutorial is made to help the student use C language

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

### Primitive Data Types Summer 2010 Margaret Reid-Miller

Primitive Data Types 15-110 Summer 2010 Margaret Reid-Miller Data Types Data stored in memory is a string of bits (0 or 1). What does 1000010 mean? 66? 'B'? 9.2E-44? How the computer interprets the string

### Adjusted/Modified by Nicole Tobias. Chapter 2: Basic Elements of C++

Adjusted/Modified by Nicole Tobias Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types

### 6.096 Lab 1. Due: 7 January 12:30:00. September 20, 2011

6.096 Lab 1 Due: 7 January 1:30:00 September 0, 011 1 Additional Material 1.1 Constants A constant is an expressions with a fixed value. Kinds of constants: Literals: used to express particular values

### Comp151. Definitions & Declarations

Comp151 Definitions & Declarations Example: Definition /* reverse_printcpp */ #include #include using namespace std; int global_var = 23; // global variable definition void reverse_print(const

### Chapter 4 C Program Control

Chapter 4 C Program Control Objectives of this chapter: Repetitions will be considered in greater detail for.. repetition do while repetition Also multiple selection switch case statement will be learned.

### Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

JAVA OPERATORS GENERAL Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups: Arithmetic Operators Relational Operators Bitwise Operators

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

### PE1 Worksheet. 3) What are the three control structures for writing an algorithm in pseudocode?

PE1 Worksheet Problem solving 1) What are the four stages of problem solving by programming? What shall be done in each stage? Stage 1: Stage 2: Stage 3: Stage 4: 2) What is the top-down design strategy

### Lecture 03 Bits, Bytes and Data Types

Lecture 03 Bits, Bytes and Data Types In this lecture Computer Languages Assembly Language The compiler Operating system Data and program instructions Bits, Bytes and Data Types ASCII table Data Types

### A First Book of C++ Chapter 2 Data Types, Declarations, and Displays

A First Book of C++ Chapter 2 Data Types, Declarations, and Displays Objectives In this chapter, you will learn about: Data Types Arithmetic Operators Variables and Declarations Common Programming Errors

### Basic Common Unix commands: Change to directory d

Basic Common Unix commands: cd d Change to directory d mkdir d rmdir d mv f1 [f2...] d mv d1 d2 ls [d] [f...] ls -1 [f...] vi [f] emacs [f] more f cp f1 f2 mv f1 f2 rm f gcc [-o f1] f2 gnuplot Create new

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

### Reading. C Programming Language. Basic syntax Whitespaces. Whitespaces (cont d) #include. Basic syntax Comments

Reading C Programming Language Types, operators, expressions Control flow, functions Basic IO K&R Chapter 2 Types, Operators, and Expressions K&R Chapter 3 Control Flow K&R Chapter 7 Basic I/O NEWS Assignment

### 6.087 Lecture 2 January 12, 2010

6.087 Lecture 2 January 12, 2010 Review Variables and data types Operators Epilogue 1 Review: C Programming language C is a fast, small,general-purpose,platform independent programming language. C is used

### E91 Embedded System. Intro

E91 Embedded System Intro Why embedded systems? Big bang-for-the-buck buck by adding some intelligence to systems. Embedded Systems are ubiquitous. Embedded Systems more common as prices drop, and power

### CSI 333 Lecture 2 Introduction to C: Part I 2 1 / 16

CSI 333 Lecture 2 Introduction to C: Part I 2 1 / 16 Basics of C Remark: Skim Chapters 1 through 6 of Deitel & Deitel. You will notice the following: C is (more or less) a subset of Java. (So, you are

### Why using ATmega16? University of Wollongong Australia. 7.1 Overview of ATmega16. Overview of ATmega16

s schedule Lecture 7 - C Programming for the Atmel AVR School of Electrical, l Computer and Telecommunications i Engineering i University of Wollongong Australia Week Lecture (2h) Tutorial (1h) Lab (2h)

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

### 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]);

### Chapter 4 Operators & Arithmetic

Chapter 4 Operators & Arithmetic 4-1 Arithmetic in C++ Arithmetic expressions can be made up of constants, variables, operators and parentheses. The arithmetic operators in C++ are as follows + (addition)

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

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

### Exercise 4 Logical Operators & Branching

Exercise 4 Logical Operators & Branching Informatik I für D-MAVT (FS 2013) Christian Schumacher chschuma@inf.ethz.ch Agenda Branching relational operators logical expressions: and, or, not if, else if,

### C Primer. Fall Introduction C vs. Java... 1

CS 33 Intro Computer Systems Doeppner C Primer Fall 2016 Contents 1 Introduction 1 1.1 C vs. Java.......................................... 1 2 Functions 1 2.1 The main() Function....................................

### C A short introduction

About these lectures C A short introduction Stefan Johansson Department of Computing Science Umeå University Objectives Give a short introduction to C and the C programming environment in Linux/Unix Go

### Operator Overloading. Lecture 8. Operator Overloading. Running Example: Complex Numbers. Syntax. What can be overloaded. Syntax -- First Example

Operator Overloading Lecture 8 Operator Overloading C++ feature that allows implementer-defined classes to specify class-specific function for operators Benefits allows classes to provide natural semantics

### J a v a Quiz (Unit 3, Test 0 Practice)

Computer Science S-111a: Intensive Introduction to Computer Science Using Java Handout #11 Your Name Teaching Fellow J a v a Quiz (Unit 3, Test 0 Practice) Multiple-choice questions are worth 2 points

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

### z = x + y * z / 4 % 2-1

1.Which of the following statements should be used to obtain a remainder after dividing 3.14 by 2.1? A. rem = 3.14 % 2.1; B. rem = modf(3.14, 2.1); C. rem = fmod(3.14, 2.1); D. Remainder cannot be obtain

### Chapter 8. Arithmetic in C++

Christian Jacob Chapter 8 Arithmetic in C++ 8.1 The C++ Vocabulary 8.2 Variables and Types 8.2.1 Data Objects 8.2.2 Variables 8.2.3 Declaration of Variables 8.3 Elementary C++ Data Types 8.3.1 Integers

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

### Chapter 2: Problem Solving Using C++

Chapter 2: Problem Solving Using C++ 1 Objectives In this chapter, you will learn about: Modular programs Programming style Data types Arithmetic operations Variables and declaration statements Common

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

### Java Review (Essentials of Java for Hadoop)

Java Review (Essentials of Java for Hadoop) Have You Joined Our LinkedIn Group? What is Java? Java JRE - Java is not just a programming language but it is a complete platform for object oriented programming.

### Introduction to Programming Block Tutorial C/C++

Michael Bader Master s Program Computational Science and Engineering C/C++ Tutorial Overview From Maple to C Variables, Operators, Statements Functions: declaration, definition, parameters Arrays and Pointers

### ELEG3924 Microprocessor Ch.7 Programming In C

Department of Electrical Engineering University of Arkansas ELEG3924 Microprocessor Ch.7 Programming In C Dr. Jingxian Wu wuj@uark.edu OUTLINE 2 Data types and time delay I/O programming and Logic operations

### UNIT-1. C Programming & Data Structures. Introduction to Computers: Computing Environment: Types of Computing Environments:

Introduction to Computers: C Programming & Data Structures UNIT-1 A computer system consists of hardware and software. Computer hardware is the collection of physical elements that comprise a computer

### DNA Data and Program Representation. Alexandre David 1.2.05 adavid@cs.aau.dk

DNA Data and Program Representation Alexandre David 1.2.05 adavid@cs.aau.dk Introduction Very important to understand how data is represented. operations limits precision Digital logic built on 2-valued

### MPI and C-Language Seminars 2010

MPI and C-Language Seminars 2010 Seminar Plan (1/3) Aim: Introduce the C Programming Language. Plan to cover: Basic C, and programming techniques needed for HPC coursework. C-bindings for the Message Passing

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

### Tutorial-3a: First steps with C++ programming

HTTP://WWW.HEP.LU.SE/COURSES/MNXB01 Introduction to Programming and Computing for Scientists (2015 HT) Tutorial-3a: First steps with C++ programming Programming for Scientists Tutorial 3a 1 / 17 Quick

### Translating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language

Translation Translating to Java Introduction to Computer Programming The job of a programmer is to translate a problem description into a computer language. You need to be able to convert a problem description

### 6.087 Lecture 3 January 13, 2010

6.087 Lecture 3 January 13, 2010 Review Blocks and Compound Statements Control Flow Conditional Statements Loops Functions Modular Programming Variable Scope Static Variables Register Variables 1 Review:

### Overview of a C Program

Overview of a C Program Programming with C CSCI 112, Spring 2015 Patrick Donnelly Montana State University Programming with C (CSCI 112) Spring 2015 2 / 42 C Language Components Preprocessor Directives

### C AND C++ PROGRAMMING

C AND C++ PROGRAMMING Bharathidasan University A Courseware prepared by University Informatics Centre Part I - Programming in C Getting Started This courseware is intended to be an introduction to C programming

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

### 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)

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

### CMSC 106 Lecture Set #2. C language syntax. Syntax vs Semantics Examples

CMSC 106 Lecture Set #2 C Language Introduction C language syntax Syntax rules of the grammar vocabulary recognized by the language ANSI standard American National Standards Institute Semantics the meaning

### C++FA 5.1 PRACTICE MID-TERM EXAM

C++FA 5.1 PRACTICE MID-TERM EXAM This practicemid-term exam covers sections C++FA 1.1 through C++FA 1.4 of C++ with Financial Applications by Ben Van Vliet, available at www.benvanvliet.net. 1.) A pointer

### 9 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

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

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

### Arrays. Arrays, Argument Passing, Promotion, Demotion

Arrays Arrays, Argument Passing, Promotion, Demotion Review Introduction to C C History Compiling C Identifiers Variables Declaration, Definition, Initialization Variable Types Logical Operators Control

### Your first C program. Which one is best?

Your first C program #include void main(void) { printf( Hello, world!\n ); } #include void main(void) { printf( Hello, ); printf( world! ); printf( \n ); } Which one is best? #include

### FORMAT MEANING VARIABLE TYPE

Printf and Scanf Both formatted I/O Both sent to standard I/O location Printf Converts values to character form according to the format string Scanf Converts characters according to the format string,

### BHARATHIAR UNIVERSITY: COIMBATORE CENTRE FOR COLLABORATION OF INDUSTRY AND INSTITUTIONS(CCII) CERTIFICATE IN ADVANCED PROGRAMMING C++ LANGUAGE

Certificate in Advanced Programming - C++ Language Page 1 of 7 BHARATHIAR UNIVERSITY: COIMBATORE 641046 CENTRE FOR COLLABORATION OF INDUSTRY AND INSTITUTIONS(CCII) CERTIFICATE IN ADVANCED PROGRAMMING C++

### An Incomplete C++ Primer. University of Wyoming MA 5310

An Incomplete C++ Primer University of Wyoming MA 5310 Professor Craig C. Douglas http://www.mgnet.org/~douglas/classes/na-sc/notes/c++primer.pdf C++ is a legacy programming language, as is other languages

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

### Format String Vulnerability. printf ( user input );

Lecture Notes (Syracuse University) Format String Vulnerability: 1 Format String Vulnerability printf ( user input ); The above statement is quite common in C programs. In the lecture, we will find out

### Final Exam Review. CS 1428 Fall Jill Seaman. Final Exam

Final Exam Review CS 1428 Fall 2011 Jill Seaman 1 Final Exam Friday, December 9, 11:00am to 1:30pm Derr 241 (here) Closed book, closed notes, clean desk Comprehensive (covers entire course) 25% of your

### The Basics of C Programming. Marshall Brain

The Basics of C Programming Marshall Brain Last updated: October 30, 2013 Contents 1 C programming 1 What is C?................................. 2 The simplest C program, I........................ 2 Spacing

### PROGRAMMING REFRESHER MODULE. Delivered by Ana Cavalcanti and Alvaro Miyazawa Prepared by Dr Lilian Blot

PROGRAMMING REFRESHER MODULE Delivered by Ana Cavalcanti and Alvaro Miyazawa Prepared by Dr Lilian Blot The Rules Everything in PREF (Week 1) is optional. From week 2 of APRC and JAPC, we assume that all

### Arrays and Pointers (part 1)

Arrays and Pointers (part 1) EECS 2031 25 September 2016 1 Arrays l Grouping of data of the same type. l Loops commonly used for manipulation. l Programmers set array sizes explicitly. 2 1 Arrays: Example

### THE JAVA SWITCH STATEMENT

THE JAVA SWITCH STATEMENT Like the if-else statement, the switch statement introduces a fork in the road for the program s execution path. Unlike the if-else (1) the switch statement s fork has many tines

### SANKALCHAND PATEL COLLEGE OF ENGINEERING, VISNAGAR ODD/EVEN ACADEMICSEMESTER (2014-15) ASSIGNMENT / QUESTION BANK (2110003) [F.Y.B.E.

SANKALCHAND PATEL COLLEGE OF ENGINEERING, VISNAGAR ODD/EVEN ACADEMICSEMESTER (2014-15) ASSIGNMENT / QUESTION BANK Subject: Computer Programming and Utilization (2110003) [F.Y.B.E.: ALL BRANCHES] Unit 1

### M3-R4: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE

M3-R4: PROGRAMMING AND PROBLEM SOLVING THROUGH C LANGUAGE NOTE: IMPORTANT INSTRUCTIONS: 1. Question Paper in English and Hindi and Candidate can choose any one language. 2. In case of discrepancies in

### Borland C++ Compiler: Operators

Introduction Borland C++ Compiler: Operators An operator is a symbol that specifies which operation to perform in a statement or expression. An operand is one of the inputs of an operator. For example,

### C programming: exercise sheet L2-STUE (2011-2012)

C programming: exercise sheet L2-STUE (2011-2012) Algorithms and Flowcharts Exercise 1: comparison Write the flowchart and associated algorithm that compare two numbers a and b. Exercise 2: 2 nd order

### Introduction to Computers and Programming

16.070 Introduction to Computers and Programming March 14 Recitation 6 Spring 2002 Topics: Quick review of PS4 issues Fundamental Data types ASCII / Arithmetic Conversion Number Systems / Logical Operation

### Chapter 2: Basic Elements of C++

Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates

### BSc (Hons) Computer Science with Network Security, BSc (Hons) Business Information Systems, BSc (Hons) Mathematics & BSc (Hons) Software Engineering

BSc (Hons) Computer Science with Network Security, BSc (Hons) Business Information Systems, BSc (Hons) Mathematics & BSc (Hons) Software Engineering Cohort: BCNS/07/FT- BIS/07/FT- BIS/06/FT -BM/07/FT BSE/07/FT/PT-

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

### FBCA-02 April-2007 Programming in C Language BCA-102 (New Course)

Seat No. : FBCA-02 April-2007 Programming in C Language BCA-102 (New Course) Time : 3 Hours] [Max. Marks : 70 Instructions : (1) Figures to the right indicate full marks of the question. (2) Make and state

### an array of 10 characters would require 10 bytes of storage for data. On the other hand, would require 10*sizeof(int) amount of storage.

Lecture 05 C Arrays & pointers In this lecture Introduction to 1D arrays Array representation, access and updates Passing arrays to functions Array as a const pointer Dynamic arrays and resizing Introduction