Programming C/C++ on Eclipe C Training Trình bày : Ths HungNM.

Slides:



Advertisements
Similar presentations
Introduction to C Programming
Advertisements

Chapter 41 Variables and JSP Control Structures JavaServer Pages By Xue Bai.
1 Today’s lecture  Last lecture we started talking about control flow in MIPS (branches)  Finish up control-flow (branches) in MIPS —if/then —loops —case/switch.
Homework Any Questions?. Statements / Blocks, Section 3.1 An expression becomes a statement when it is followed by a semicolon x = 0; Braces are used.
1 Chapter 4 Language Fundamentals. 2 Identifiers Program parts such as packages, classes, and class members have names, which are formally known as identifiers.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 4: Control Structures I (Selection)
Logical Operators Java provides two binary logical operators (&& and ||) that are used to combine boolean expressions. Java also provides one unary (!)
Primitive Types Java supports two kinds of types of values – objects, and – values of primitive data types variables store – either references to objects.
JavaScript, Third Edition
Arrays. Objectives Learn about arrays Explore how to declare and manipulate data into arrays Learn about “array index out of bounds” Become familiar with.
COMP1170 Midterm Preparation (March 17 th 2009) Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education.
VB .NET Programming Fundamentals
Introduction to C Language
Basics of “C” Programming
© Janice Regan, CMPT 128, Jan CMPT 128: Introduction to Computing Science for Engineering Students Data representation and Data Types Variables.
Variables and Data Types
Fundamentals of C and C++ Programming Control Structures and Functions.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
2440: 211 Interactive Web Programming Expressions & Operators.
C Tokens Identifiers Keywords Constants Operators Special symbols.
JAVA Tokens. Introduction A token is an individual element in a program. More than one token can appear in a single line separated by white spaces.
Introduction to Computer Systems and the Java Programming Language.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
1 © 2002, Cisco Systems, Inc. All rights reserved. Arrays Chapter 7.
Chapter 7 Additional Control Structures. Chapter 7 Topics l Switch Statement for Multi-Way Branching l Do-While Statement for Looping l For Statement.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
Basic Java Syntax COMP 401, Spring 2014 Lecture 2 1/14/2014.
1 Operators and Expressions. Expressions Combination of Operators and Operands Example 2 * y + 5 Operands Operators.
VARIABLES, CONSTANTS, OPERATORS ANS EXPRESSION
Java Language Basics By Keywords Keywords of Java are given below – abstract continue for new switch assert *** default goto * package.
Java Nuts and Bolts Variables and Data Types Operators Expressions Control Flow Statements Arrays and Strings.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Operators & Expressions
2: Basics Basics Programming C# © 2003 DevelopMentor, Inc. 12/1/2003.
Chapter 1 Java Programming Review. Introduction Java is platform-independent, meaning that you can write a program once and run it anywhere. Java programs.
Department of Electronic & Electrical Engineering Expressions operators operands precedence associativity types.
INTRODUCTION TO ‘C’ PROGRAMMING BY Prof. P. PADMANABHAM M.Tech (AE), M.Tech(CS), Ph.D(CS)-FIETE, FIE Director Academics, Bharat Institute Of Engineering.
Session 2 Operators, Decisions and Loops. Objectives Operators Casting data Decision marking structures Loops break, continue, return.
Java Basics. Tokens: 1.Keywords int test12 = 10, i; int TEst12 = 20; Int keyword is used to declare integer variables All Key words are lower case java.
Department of Electronic & Electrical Engineering Lecture 3 IO reading and writing variables scanf printf format strings "%d %c %f" Expressions operators.
JAVA Programming (Session 2) “When you are willing to make sacrifices for a great cause, you will never be alone.” Instructor: รัฐภูมิ เถื่อนถนอม
 Array ◦ Single & Multi-dimensional  Java Operators ◦ Assignment ◦ Arithmetic ◦ Relational ◦ Logical ◦ Bitwise & other.
Unit – 3 Control structures. Condition Statements 1.If.…..else :- Has someone ever told you, "if you work hard, then you will succeed"? And what happens.
Lecture 3.1 Operators and Expressions Structured Programming Instructor: Prof. K. T. Tsang 1.
OPERATORS IN C CHAPTER 3. Expressions can be built up from literals, variables and operators. The operators define how the variables and literals in the.
Windows Programming Lecture 03. Pointers and Arrays.
Expressions and Assignment Statements
Chapter 4 – C Program Control
Chapter 12 Variables and Operators
Operators and Expressions
BASIC ELEMENTS OF A COMPUTER PROGRAM
Programming in Java Sachin Malhotra, Chairperson, PGDM-IT, IMS Ghaziabad Saurabh Chaudhary, Dean, Academics, IMS Ghaziabad.
Chapter 12 Variables and Operators
Expressions and Control Flow in JavaScript
JavaScript: Control Statements I
11/10/2018.
Arrays, For loop While loop Do while loop
Introduction to Programming
Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Character Set Uppercase Alphabets A,
Java - Data Types, Variables, and Arrays
An Introduction to Java – Part I, language basics
Chapter 7 Additional Control Structures
Introduction to C Programming
C Operators, Operands, Expressions & Statements
3 Control Statements:.
Primitive Types and Expressions
Basic Programming Concepts
Chap 7. Advanced Control Statements in Java
C Language B. DHIVYA 17PCA140 II MCA.
Review of Java Fundamentals
Presentation transcript:

Programming C/C++ on Eclipe C Training Trình bày : Ths HungNM

Training C/C++Ecosoftware 2 Programming C Overview cource

Training C/C++Ecosoftware 3 Introduction C o 1. Introduction C o 2. C Program Structure o 3. C Development Environment o 4. Eclipse Environment o 5. Variable and Data types o 6. Statement and Operator o 7. C Programming Construct o 8. Array

Training C/C++Ecosoftware 4 1. Introduction C o C was initially used for systems programming o Middle Level Language  High language Level  Assembly language o Structured Language C

Training C/C++Ecosoftware 5 Introduction C o C has 32 keywords o These keywords combined with a formal syntaxform a C programming language o Rules to be followed for all programs written in C:  All keywords are lowercased  C is case sensitive, do while is different from DO WHILE  Keywords cannot be used as a variable or function name main() { /* This is a sample Program*/ int i,j; i=100; j=200; : }

Training C/C++Ecosoftware 6 2. C Program Structure 1

Training C/C++Ecosoftware 7 2. C Program Structure 2

Training C/C++Ecosoftware 8 2. C Program Structure 3

Training C/C++Ecosoftware 9 2. C Program Structure 4

Training C/C++Ecosoftware C Program Structure 5

Training C/C++Ecosoftware C Development Environment o Six phases :  Edit  Preprocess  Compile  Link  Load  Execute

Training C/C++Ecosoftware C Development Environment o Six phases :  Edit  Preprocess  Compile  Link  Load  Execute

Training C/C++Ecosoftware Eclipse Environment o Step 1 : Create a project o Step 2 : Reviewing the code and Building project o Step 3 : Run a Program

Training C/C++Ecosoftware Eclipse Environment o Step 1 : Create a project

Training C/C++Ecosoftware Eclipse Environment o Step 2 : Reviewing the code and Building project  Choose source code  Save for change  Build your project (using gcc or ctrl+B)  Read through the build message in the console view o Step 3:  Choose run application  Run > Run Configurations…

Training C/C++Ecosoftware 16 Example o Write simple example with Eclipse.

Training C/C++Ecosoftware Variables and Data types o Variables allow to provide a meaningful name for the location in memory Data Memory Each location in the memory is unique 15 Data in memory 15

Training C/C++Ecosoftware Identifier Variables o The names of variables, functions, labels, and various other user defined objects are called identifiers o Some correct identifier names  arena  s_count  marks40  class_one o Examples of erroneous identifiers  1sttest  oh!god  start... end o Identifiers can be of any convenient length, but the number of characters in a variable that are recognized by a compiler varies from compiler to compiler o Identifiers in C are case sensitive

Training C/C++Ecosoftware Keywords autoenumrestrictunsigned breakexternreturnvoid casefloatshortvolatile charforsighedwhile continuegotosizeof_Bool defaultIfstatic_Complex doinlinestructure_Imaginary doubleintswitch elselongtypedef unionregister

Training C/C++Ecosoftware Data types o Value types  Variable of value type store actual values o Pointer types  Variables that can store addresses are called pointers  The address that’s stored in a pointer is usually that of another variable

Training C/C++Ecosoftware 21 Value types

Training C/C++Ecosoftware 22 Simple Declaration main () { char abc; /*abc of type character */ int xyz; /*xyz of type integer */ float length; /*length of type float */ double area; /*area of type double */ long liteyrs; /*liteyrs of type long int */ short arm; /*arm of type short integer*/ }

Training C/C++Ecosoftware 23 Pointer types main () { int number = 5; int *p = &number ; } How a pointer works

Training C/C++Ecosoftware 24 Example o Example with basic data types o Example with pointers

Training C/C++Ecosoftware 25 Example o Example with basic data types

Training C/C++Ecosoftware 26 Example o Example with Pointers

Training C/C++Ecosoftware Statement and Operator o Type Statement  Selection statements  Iteration statements  Jump statements o Operators  Arithmetic operators  Relational Operators  Logical Operators  Conditional Operators  Increment and Decrement Operators  Assignment operators

Training C/C++Ecosoftware Type Statement o Selection statements  If, else, switch and case o Iteration statements  do, for, while o Jump statements  Break, continue, goto, return

Training C/C++Ecosoftware Operators o Arithmetic operators

Training C/C++Ecosoftware Operators o Relational Operators o Logical Operators Logical OperatorsDescriptionExample &&Return 1 if both the expression are evaluated to 1 ||Return 1 if at least one of the expression is evaluated to 1 !Return 1 if only one of the expression is evaluated to 1…

Training C/C++Ecosoftware Operators o Bitwise Logical Operators Bitwise Logical Operators AND ( NUM1 & NUM2) Return 1 if both the operands are 1 OR ( NUM1 | NUM2 ) Returns 1 if bits of either of the operand are 1 NOT ( ~ NUM1) Reverses the bits of its operand ( from 0 to 1 and 1 to 0) XOR ( NUM1 ^ NUM2) Returns 1 if either of the bits in an operand is 1 but not both

Training C/C++Ecosoftware Operators o Example Bitwise Logical Operators

Training C/C++Ecosoftware Operators o Conditional Operators  #define True = 1;  #define False = 0;

Training C/C++Ecosoftware Operators o Increment and Decrement Operators  Increment operator (++) use to increment the value by 1  Decrement operator (--) use to decrement the value by 1

Training C/C++Ecosoftware Operators o Assignment operation  Simple assignment operation.  Compound assignment operation.

Training C/C++Ecosoftware Operators o Precedence of operators 1. Operator ClassOperatorsAssociativity Unary Right to Left Binary^Left to Right Binary* / %Left to Right Binary+ -Left to Right Binary=Right to Left

Training C/C++Ecosoftware Operators o Precedence of operators 2 - Example

Training C/C++Ecosoftware Operators o Type conversion

Training C/C++Ecosoftware 39 Example o Example with Operator

Training C/C++Ecosoftware C Programming Construct o Selection construct o Loop construct o Jump statements

Training C/C++Ecosoftware Selection contruct o if else constructs o if..else if constructs o Nested if constructs o switch statements

Training C/C++Ecosoftware Loop contructs o while o do while o for

Training C/C++Ecosoftware 43 Example o Example Selection

Training C/C++Ecosoftware 44 Example o Example with Loop contructs

Training C/C++Ecosoftware 45 8.Array o Introduction Array o One-Dimensional o Multi-Dimensional

Training C/C++Ecosoftware Introduction Array o Each member of an array is identified by unique index or subscript assigned to it. o The dimension of an array is determined by the number of indices needed to uniquely identify each element o An index holds integer values starting with zero o An index is a positive integer enclosed in [ ] placed immediately after the array name

Training C/C++Ecosoftware One-Dimensional o Declaring Array type array-Name[array-size];  int c[12]; // c is array of 12 integers o Init element of array  int c[5] = {}; // init element of integer for 0  int c[5] = {1,3,5,7,10}; // o Interaction with array  Using loop statement : for, while, do-while

Training C/C++Ecosoftware 48 Example One-Dimensional

Training C/C++Ecosoftware Multi-Dimensional o Declaring Array type array-Name[array-size];  int c[4][3]; // c is array 2 dimensions of integers o Init element of array  int c[2][2] = {{1,1},2,4}; // init element for array o Using nested loop for interaction with array

Training C/C++Ecosoftware 50 Example Multi-Dimensional

Training C/C++Ecosoftware 51 Thank You End