Embedded Systems. Introduction. The C Language. Introduction. Why C instead ASM. Introduction to C Embedded Programming language
|
|
- Earl Little
- 6 years ago
- Views:
Transcription
1 Introduction Embedded Systems Introduction to C Embedded Programming language Why C instead ASM 1. C is a high level language, it is easier to write and read than assembly codes. 2. You don't have to think about hardware logic with C, this is taken care of in the background. 3. C codes can be compiled for different microcontrollers without significant modifications of code. 1 3 Introduction In this lecture we will cover the fundamentals of the C programming language as it applies to embedded microcontroller applications. 2 The C Language The C language is function based programming language. Function consists of: 1. A Return Type 2. The Function Name 3. Followed by parentheses enclosing arguments or an empty pair of parentheses if there are not arguments required. f ( x) = x int cube (int x) = x 3 3 y = Integers f (x) y = cube(3) 4 1
2 while(1); The C Language A C program itself is a function. All C program MUST have a main() function. This function must be included in every program because this is the function which is run when the program is executed. An embedded C program in its simplest form: // do forever 5 The C Language #include <stdio.h> This is a preprocessor command. All preprocessor commands are identified by the # sign. The #include command tells the preprocessor to open filestdio.handcompile itasapartoftheprogram. Nextlineisvoidmain(). It is always necessary to define the type of function, its return type and of course whether the function has any arguments. The type void indicates that this main() function does not return an output and the empty brackets indicates that the function takes no inputs. An open brace indicates the beginning of the block of statements within the function and the function closes with a closing brace. 7 The C Language C Preprocessor Commands #include <avr/io.h> // AVR Header File #include <avr/io.h> // AVR Header File int n; DDRB = 0xFF; DDRA = 0x00; while(1) // do forever PORTB = PINA; 6 Preprocessing, this is the first stage of any C program during compilation. Preprocessor commands are used to combine header files to the mainfiles. During the preprocessing stage, symbols, macros and constants are defined. With the help of preprocessor commands programs become easier to develop and modify. The preprocessor is directed using # symbol at the beginning of the command. All preprocessor commands start with a #. 8 2
3 C Preprocessor Commands #include : This directive is used to include external c files and headers that are needed for the compilation of a specific project. The#include is used in the following way,#include <filename>. #include <avr/io.h> // General header files #include <avr/interrupt.h> Variables Types Variables are simple keywords which are defined by the values. Values can be changed. Variables are like a boxes with some size where values like apples canbeputin.sovariablescanbeofvariousformsandsizes. A variable type is defined by a reserved word which indicates the type and size of variable identifier: unsigned char Peabody; #include "uart.h" // User s own header files #include "lcd.h" int dogs, cats; long int total_dogs_and_cats; 9 11 C Preprocessor Commands Variables Types #define: This directive allows the programmer to construct constants and macro commands needed for a project. The #define is used in the following way, #define identifier value #define BAUD_RATE 9600UL #define F_CPU UL // Named constant // Frequency of the clock There are other preprocessor directives that are used in C but not as widelyusedastheonesabove
4 Variables Types Constant A Constant value is understandable as being non-changeable value like the (pi= ) value in math. Usually you use constants in your programs, but don't realize that they are constants. For instance: x = x + 3; The number 3 is a constant which will be compiled directly in addition operation. Constants canalsobeacharacterorstring. It is usually recommended to declare constants by using identifier with reserved word const: const int No = 44; Global & Local Variables unsigned char globley; void function_z (void) unsigned int tween; tween = 12; globley = 47; main_loc = 12; unsigned char main_loc; Variables Scope // global variable // a function //local variable //OK //OK //ERROR // local variable #include <avr/io.h> unsigned char z; DDRB = 0xff; DDRA = 0x00; while(1) z = PINA; I/O Operations // Declare z // Set all pins on port B for output // Set all pins on port A for input globley = 34; tween = 12; while(1); //OK //ERROR // do forever PORTB = z + 1;
5 Operators These are symbols that tells the compiler which type of operation is to be performed. Assume that an unsigned char y = 0xC9 Note: There are certain rules that governs the order in which operations are performed. Once a variable has been declared, operations can be performed on them. Below are some of the typical arithmetic operations that are usually carried out on variables. Multiplication(*) Division(/) Modulo(%) Addition (+) Subtraction/ Negation(-) 17 Operation x = ~y; x = y <<3; x = y >>4; x = y ^1; x =y 0x10; Results x = 0x36 x = 0x48 x = 0x0C x = 0xC8 x = 0xD9 19 Bitwise Operation These operators perform functions that will affect an operand onthebitlevel. These operators work on non-floating point operands such as char and int. There are six bitwise operators: OnesComplement(~) LeftShift(<<) RightShift(>>) AND(&) ExclusiveOR-(XOR)(^) OR(InclusiveOR)( ) 18 Logical and Relational Operators: These are binary operations that gives a Boolean result. This means that expressions with these operators return TRUE or FALSE values. ZeroistakenasFALSEandanon-zerovalueistakenasTRUE. Logical operators are: Negation or NOT(!) logicaland && logical OR 20 5
6 Relational Operators: These operators are used in operations where a comparison is to be made. In essence these operators ask about the relationship of two expressions in order to gain a TRUE or FALSE reply. These operators include: Is Equal to (== ) Is Not Equal to (!=) Less Than ( <) Less Than or Equal to (<= ) Greater Than (> ) Greater Than or Equal to (>= ) Here is an example; ( x ==y ) FALSE Assume that x = 3and y = 5. ( x!=y) TRUE 21 ( x >y ) FALSE Bit masking is a operation where single bits of a variable or register are changed. Bit masking is a common way to control microcontroller s peripherals (I/O) since single bits in microcontroller s registers represent some change to the state of the system, for example, enabling interrupts. Logical operators AND (&), OR ( ), XOR ( ˆ ) and COMPLEMENT ( ) are utilised to change single bits in a register without modifying the rest bits of the register value. In addition, SHIFT (<<, >>) operators are used to simplify changing the known bit in the register. 23 Note that the equality operator is == and not =. The equality sign alone( = ) is an assignment operator. Ifyouwanttocomparetwovaluesforequalitythen == shouldbe used instead of =.For instance if wewish to assign the valueof a tobwewritea=b. Ifwewanttocheckifthevalueofbisequaltoa,wewritea==b. The following code example shows how bit values are changed to attain the required register value. Set and clear single bit PORTA = PORTA 0x20; // Set bit 5 (bits 0, 1,..., 7) DDRA = DDRA & ~0x20; // Clear bit 5 DDRA = DDRA (1 << 5); // Set bit 5 using shift operator Set and clear multiple bits PORTD = PORTD 0x50; // Set bits 4 and 6 DDRD = DDRD & ~0x50; // Clear bits 4 and 6 PORTD = (PORTD << 4); // Shifting PORTD 4 bits to left
7 Increment operators: This operator modifies the value of a variable by increasing it by 1. Increment operators can be applied to variables as prefix or postfix, for example, x=x+1;isthesameas ++x; // pre increment operation x++; // post increment operation Decrement operators: This operator modifies the value of a variable by decreasing it by 1. Decrement operators can be applied to variables as prefix or postfix, for example: y=y-1 isthesameas --y y-- // pre increment operation // post increment operation Letstakeaquicklookatanexample; Leta=1;and b=3*a++; Whatisthevalueofaandbrespectively? b=3anda=2. Nowleta=1;and b=3*++a; Whatisthevalueofaandbrespectively? b=6anda=2. 26 Compound Assignment Operators: These operators are used as a method to reduce the amount syntax required during the construction of a program. Here are some examples: (i) a+=3; //a=a+3 (ii) b-=3; //b=b 3 (iii)c*=5; //c=c*5 (iv)d/=a; //d=d/a (v)porta =0x20; //PORTA=PORTA 0x20 (vi)ddra&=~0x20;//ddra=ddra&(~0x20) NB, these expressions are processed from right to left. 28 7
8 Operator Precedence Rules Name Level Operators Order of evaluation Primary 1 [ ] ( ) -> L to R Unary 2 + sizeof ( )! ++ R to L Binary 3 * / % L to R Arithmetic L to R Shift 5 << >> L to R Relational 6 < <= > >= L to R Control statements are used to control the flow of execution of a program. Among these statements are if/else, switch/case, and loop sentence likewhile,dowhile,and for. If/else statements are used to guide or branch an operation in either one of two directions. Theloopstatements(while,dowhile and for) areusedto controlthe repetition of a block of instructions. switch/case statements are used to make a decision from a block of severalinstructionsinorder to allow theprogram to flow inaconcise manner Name Level Operators Order of evaluation Equality 7 ==!= L to R Bitwise 8 & L to R Bitwise 9 ^ L to R Bitwise 10 L to R Logical 11 && L to R Logical 12 L to R Conditional 13?: R to L Assignment 14 &= -= = <<= >>= R to L The While Loop This is one of the most basic control elements of a program. The format in which the whilestatement is used is as follows: while(expression) or while(expression) statement; statement1; statement2;
9 #include <stdio.h> unsigned char c; c = 1; printf("start of program \n"); while(c <= 100) printf("c = %d\n", int(c)); c++; printf("end of program \n"); while(1); This loop is often used where data is to be read. The test then verifies the data, and loops back to read again if it was unacceptable. The format of the do/whilestatement is as follows. do or do statement; statement1; while (expression); statement2; while(expression); The do/while Loop This is very similar to the while loop except that the expression is tested after the loop body has been executed one time. This means that the instructions in a do/while loop areexecuted atleastoncebeforethedecisionismade onwhetherornottoremainintheloop. In the while construct, the test is made before the instructions in the loop are executed even once. 34 #include <stdio.h> unsigned char c; c = 0; printf("start of program \n"); do printf("c = %d\n", int(c)); c++; while(c < 100); printf("end of program \n"); while(1); 36 9
10 TheForLoop A for loop construct is usually used to execute a statement or a statement block for a specific number of times. This construct takes three arguments each separated by semi-colons. 1. The first is run before the loop is entered. This is usually the initialisation of the loop variable. 2. Thesecond isatest, theloopisexitedwhenthisreturnsfalse. 3. The third is a statement to be run every time the loop body is completed. The for loop is extremely flexible and allows many types of program behaviour to be specified simply and quickly. The if/else statements are used to guide or branch the operation of the program based on the evaluation of a conditional statement. An if/else statement has the form; If (expression) statement1; statement1; else statement1; statement2; #include <stdio.h> unsigned char c; c = 0; printf("start of program \n"); for(c = 1; c <= 100; c++) printf("c = %d\n", int(c)); printf("end of program \n"); while(1); 38 The following test decides whether a student has passed an exam with a pass markof40 if(result>=40) printf("pass\n"); else printf("fail\n"); Other case is with if/else if sentence structure: if(expression1) statement1; else if(expression2) statement2; else if(expression3) statement3;... else(expression n) statement n; 40 10
11 #include <stdio.h> unsigned char c; c = 0; printf("start of program \n"); for(c = 0; c < 100; c++) printf("end of program \n"); while(1); if(c < 33) printf("0<c<33 "); else if ((c>32) && (c<66)) printf("33<c<66"); else printf("66<c<100"); 41 A switch/case statement is written in the following way. switch (expression) case constant1: statement1; statement2; case constant2: statement3; statement4; case constant3: statement5; statement6; default: statement7; 43 The switch case statement is used to execute a statement, or a group of statements selected by the value of an expression. This control statement is used in cases where; Only one variable (expression) is tested, all branches must depend upon the value of that variable (expression). The variable must be an integer type. Each possible value of the variable(expression) controls a branch. 42 unsigned char displayled(unsigned char blink) unsigned char display = 0; switch(blink) case 1 : display = 0b ; case 2 : display = 0b ; case 3 : display = 0b ; case 4 : display = 0b ; default : display = 0b ; return display; 44 11
12 Posted on website Assignment 2 Due: Tuesday 45 12
Operators. Java operators are classified into three categories:
Operators Operators are symbols that perform arithmetic and logical operations on operands and provide a meaningful result. Operands are data values (variables or constants) which are involved in operations.
More informationShort introduction to C for AVR
Short introduction to C for AVR (http://winavr.scienceprog.com/short-introduction-to-c), (www.smileymicros.com), (https://ccrma.stanford.edu/wiki/avr_programming#anatomy_of_a_c_program_for_avr) (AVR035:
More informationCprE 288 Introduction to Embedded Systems Exam 1 Review. 1
CprE 288 Introduction to Embedded Systems Exam 1 Review http://class.ece.iastate.edu/cpre288 1 Overview of Today s Lecture Announcements Exam 1 Review http://class.ece.iastate.edu/cpre288 2 Announcements
More informationFundamental of Programming (C)
Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi Lecture 3 Constants, Variables, Data Types, And Operations Department of Computer Engineering
More informationIntroduction. Following are the types of operators: Unary requires a single operand Binary requires two operands Ternary requires three operands
Introduction Operators are the symbols which operates on value or a variable. It tells the compiler to perform certain mathematical or logical manipulations. Can be of following categories: Unary requires
More informationFundamentals of Programming
Fundamentals of Programming Lecture 3 - Constants, Variables, Data Types, And Operations Lecturer : Ebrahim Jahandar Borrowed from lecturer notes by Omid Jafarinezhad Outline C Program Data types Variables
More informationCT 229 Java Syntax Continued
CT 229 Java Syntax Continued 29/09/2006 CT229 Lab Assignments One Week Extension for Lab Assignment 1. Due Date: Oct 8 th Before submission make sure that the name of each.java file matches the name given
More informationUNIT- 3 Introduction to C++
UNIT- 3 Introduction to C++ C++ Character Sets: Letters A-Z, a-z Digits 0-9 Special Symbols Space + - * / ^ \ ( ) [ ] =!= . $, ; : %! &? _ # = @ White Spaces Blank spaces, horizontal tab, carriage
More informationPart I Part 1 Expressions
Writing Program in C Expressions and Control Structures (Selection Statements and Loops) Jan Faigl Department of Computer Science Faculty of Electrical Engineering Czech Technical University in Prague
More informationWriting Program in C Expressions and Control Structures (Selection Statements and Loops)
Writing Program in C Expressions and Control Structures (Selection Statements and Loops) Jan Faigl Department of Computer Science Faculty of Electrical Engineering Czech Technical University in Prague
More informationA complex expression to evaluate we need to reduce it to a series of simple expressions. E.g * 7 =>2+ 35 => 37. E.g.
1.3a Expressions Expressions An Expression is a sequence of operands and operators that reduces to a single value. An operator is a syntactical token that requires an action be taken An operand is an object
More informationEDIABAS BEST/2 LANGUAGE DESCRIPTION. VERSION 6b. Electronic Diagnostic Basic System EDIABAS - BEST/2 LANGUAGE DESCRIPTION
EDIABAS Electronic Diagnostic Basic System BEST/2 LANGUAGE DESCRIPTION VERSION 6b Copyright BMW AG, created by Softing AG BEST2SPC.DOC CONTENTS CONTENTS...2 1. INTRODUCTION TO BEST/2...5 2. TEXT CONVENTIONS...6
More informationUnit 3. Operators. School of Science and Technology INTRODUCTION
INTRODUCTION Operators Unit 3 In the previous units (unit 1 and 2) you have learned about the basics of computer programming, different data types, constants, keywords and basic structure of a C program.
More informationProgramming in C++ 5. Integral data types
Programming in C++ 5. Integral data types! Introduction! Type int! Integer multiplication & division! Increment & decrement operators! Associativity & precedence of operators! Some common operators! Long
More informationCourse Outline Introduction to C-Programming
ECE3411 Fall 2015 Lecture 1a. Course Outline Introduction to C-Programming Marten van Dijk, Syed Kamran Haider Department of Electrical & Computer Engineering University of Connecticut Email: {vandijk,
More informationCharacter Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9
Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Uppercase Alphabets Lowercase Alphabets Character Set A, B, C, Y, Z a, b, c, y, z Digits
More informationReview of the C Programming Language for Principles of Operating Systems
Review of the C Programming Language for Principles of Operating Systems Prof. James L. Frankel Harvard University Version of 7:26 PM 4-Sep-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights
More informationGO - OPERATORS. This tutorial will explain the arithmetic, relational, logical, bitwise, assignment and other operators one by one.
http://www.tutorialspoint.com/go/go_operators.htm GO - OPERATORS Copyright tutorialspoint.com An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations.
More informationUNIT IV 2 MARKS. ( Word to PDF Converter - Unregistered ) FUNDAMENTALS OF COMPUTING & COMPUTER PROGRAMMING
( Word to PDF Converter - Unregistered ) http://www.word-to-pdf-converter.net FUNDAMENTALS OF COMPUTING & COMPUTER PROGRAMMING INTRODUCTION TO C UNIT IV Overview of C Constants, Variables and Data Types
More informationOperators in C. Staff Incharge: S.Sasirekha
Operators in C Staff Incharge: S.Sasirekha Operators An operator is a symbol which helps the user to command the computer to do a certain mathematical or logical manipulations. Operators are used in C
More informationExpressions. Arithmetic expressions. Logical expressions. Assignment expression. n Variables and constants linked with operators
Expressions 1 Expressions n Variables and constants linked with operators Arithmetic expressions n Uses arithmetic operators n Can evaluate to any value Logical expressions n Uses relational and logical
More informationA flow chart is a graphical or symbolic representation of a process.
Q1. Define Algorithm with example? Answer:- A sequential solution of any program that written in human language, called algorithm. Algorithm is first step of the solution process, after the analysis of
More informationCHW 469 : Embedded Systems
CHW 469 : Instructor: Dr. Ahmed Shalaby http://bu.edu.eg/staff/ahmedshalaby14# https://piazza.com/fci.bu.edu.eg/spring2017/chw469/home Assignment no. 3 kindly read the following paper [Software Engineering
More informationME 461 C review Session Fall 2009 S. Keres
ME 461 C review Session Fall 2009 S. Keres DISCLAIMER: These notes are in no way intended to be a complete reference for the C programming material you will need for the class. They are intended to help
More informationMore Programming Constructs -- Introduction
More Programming Constructs -- Introduction We can now examine some additional programming concepts and constructs Chapter 5 focuses on: internal data representation conversions between one data type and
More informationComputers Programming Course 6. Iulian Năstac
Computers Programming Course 6 Iulian Năstac Recap from previous course Data types four basic arithmetic type specifiers: char int float double void optional specifiers: signed, unsigned short long 2 Recap
More informationSECTION II: LANGUAGE BASICS
Chapter 5 SECTION II: LANGUAGE BASICS Operators Chapter 04: Basic Fundamentals demonstrated declaring and initializing variables. This chapter depicts how to do something with them, using operators. Operators
More informationDepartment of Computer Science
Department of Computer Science Definition An operator is a symbol (+,-,*,/) that directs the computer to perform certain mathematical or logical manipulations and is usually used to manipulate data and
More informationUIC. C Programming Primer. Bharathidasan University
C Programming Primer UIC C Programming Primer Bharathidasan University Contents Getting Started 02 Basic Concepts. 02 Variables, Data types and Constants...03 Control Statements and Loops 05 Expressions
More informationQuick Reference Guide
SOFTWARE AND HARDWARE SOLUTIONS FOR THE EMBEDDED WORLD mikroelektronika Development tools - Books - Compilers Quick Reference Quick Reference Guide with EXAMPLES for Basic language This reference guide
More informationThe C Programming Language Guide for the Robot Course work Module
The C Programming Language Guide for the Robot Course work Module Eric Peasley 2018 v6.4 1 2 Table of Contents Variables...5 Assignments...6 Entering Numbers...6 Operators...7 Arithmetic Operators...7
More informationOperators and Expressions:
Operators and Expressions: Operators and expression using numeric and relational operators, mixed operands, type conversion, logical operators, bit operations, assignment operator, operator precedence
More informationThe Arithmetic Operators. Unary Operators. Relational Operators. Examples of use of ++ and
The Arithmetic Operators The arithmetic operators refer to the standard mathematical operators: addition, subtraction, multiplication, division and modulus. Op. Use Description + x + y adds x and y x y
More informationThe Arithmetic Operators
The Arithmetic Operators The arithmetic operators refer to the standard mathematical operators: addition, subtraction, multiplication, division and modulus. Examples: Op. Use Description + x + y adds x
More informationLecture 3. More About C
Copyright 1996 David R. Hanson Computer Science 126, Fall 1996 3-1 Lecture 3. More About C Programming languages have their lingo Programming language Types are categories of values int, float, char Constants
More informationProgramming for Engineers Iteration
Programming for Engineers Iteration ICEN 200 Spring 2018 Prof. Dola Saha 1 Data type conversions Grade average example,-./0 class average = 23450-67 893/0298 Grade and number of students can be integers
More informationC Programming Language (Chapter 2 of K&R) Variables and Constants
C Programming Language (Chapter 2 of K&R) Types, Operators and Expressions Variables and Constants Basic objects manipulated by programs Declare before use: type var1, var2, int x, y, _X, x11, buffer;
More informationDEPARTMENT OF MATHS, MJ COLLEGE
T. Y. B.Sc. Mathematics MTH- 356 (A) : Programming in C Unit 1 : Basic Concepts Syllabus : Introduction, Character set, C token, Keywords, Constants, Variables, Data types, Symbolic constants, Over flow,
More informationOperators and Expressions in C & C++ Mahesh Jangid Assistant Professor Manipal University, Jaipur
Operators and Expressions in C & C++ Mahesh Jangid Assistant Professor Manipal University, Jaipur Operators and Expressions 8/24/2012 Dept of CS&E 2 Arithmetic operators Relational operators Logical operators
More informationPart I Part 1 Expressions
Writing Program in C Expressions and Control Structures (Selection Statements and Loops) Jan Faigl Department of Computer Science Faculty of Electrical Engineering Czech Technical University in Prague
More informationChapter 4: Basic C Operators
Chapter 4: Basic C Operators In this chapter, you will learn about: Arithmetic operators Unary operators Binary operators Assignment operators Equalities and relational operators Logical operators Conditional
More informationExpressions and Precedence. Last updated 12/10/18
Expressions and Precedence Last updated 12/10/18 Expression: Sequence of Operators and Operands that reduce to a single value Simple and Complex Expressions Subject to Precedence and Associativity Six
More informationChapter 3: Operators, Expressions and Type Conversion
101 Chapter 3 Operators, Expressions and Type Conversion Chapter 3: Operators, Expressions and Type Conversion Objectives To use basic arithmetic operators. To use increment and decrement operators. To
More informationBasic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators. JAVA Standard Edition
Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators JAVA Standard Edition Java - Basic Operators Java provides a rich set of operators to manipulate variables.
More informationBy the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program
1 By the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program variables. Apply C++ syntax rules to declare variables, initialize
More informationFundamental of C programming. - Ompal Singh
Fundamental of C programming - Ompal Singh HISTORY OF C LANGUAGE IN 1960 ALGOL BY INTERNATIONAL COMMITTEE. IT WAS TOO GENERAL AND ABSTRUCT. IN 1963 CPL(COMBINED PROGRAMMING LANGUAGE) WAS DEVELOPED AT CAMBRIDGE
More informationOperators & Expressions
Operators & Expressions Operator An operator is a symbol used to indicate a specific operation on variables in a program. Example : symbol + is an add operator that adds two data items called operands.
More informationLe L c e t c ur u e e 2 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Variables Operators
Course Name: Advanced Java Lecture 2 Topics to be covered Variables Operators Variables -Introduction A variables can be considered as a name given to the location in memory where values are stored. One
More informationLecture 2: C Programming Basic
ECE342 Introduction to Embedded Systems Lecture 2: C Programming Basic Ying Tang Electrical and Computer Engineering Rowan University 1 Facts about C C was developed in 1972 in order to write the UNIX
More information3. EXPRESSIONS. It is a sequence of operands and operators that reduce to a single value.
3. EXPRESSIONS It is a sequence of operands and operators that reduce to a single value. Operator : It is a symbolic token that represents an action to be taken. Ex: * is an multiplication operator. Operand:
More informationJava 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
More informationProgramming with Java
Programming with Java Data Types & Input Statement Lecture 04 First stage Software Engineering Dep. Saman M. Omer 2017-2018 Objectives q By the end of this lecture you should be able to : ü Know rules
More informationQUIZ. 1. Explain the meaning of the angle brackets in the declaration of v below:
QUIZ 1. Explain the meaning of the angle brackets in the declaration of v below: This is a template, used for generic programming! QUIZ 2. Why is the vector class called a container? 3. Explain how the
More informationJAVA OPERATORS GENERAL
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
More informationBasic C Programming (2) Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island
Basic C Programming (2) Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Data Types Basic Types Enumerated types The type void Derived types
More informationWill introduce various operators supported by C language Identify supported operations Present some of terms characterizing operators
Operators Overview Will introduce various operators supported by C language Identify supported operations Present some of terms characterizing operators Operands and Operators Mathematical or logical relationships
More informationQuick Reference Guide
SOFTWARE AND HARDWARE SOLUTIONS FOR THE EMBEDDED WORLD mikroelektronika Development tools - Books - Compilers Quick Reference Quick Reference Guide with EXAMPLES for Pascal language This reference guide
More informationMechatronics and Microcontrollers. Szilárd Aradi PhD Refresh of C
Mechatronics and Microcontrollers Szilárd Aradi PhD Refresh of C About the C programming language The C programming language is developed by Dennis M Ritchie in the beginning of the 70s One of the most
More informationFundamental Data Types. CSE 130: Introduction to Programming in C Stony Brook University
Fundamental Data Types CSE 130: Introduction to Programming in C Stony Brook University Program Organization in C The C System C consists of several parts: The C language The preprocessor The compiler
More informationOperators And Expressions
Operators And Expressions Operators Arithmetic Operators Relational and Logical Operators Special Operators Arithmetic Operators Operator Action Subtraction, also unary minus + Addition * Multiplication
More informationChapter 12 Variables and Operators
Chapter 12 Variables and Operators Highlights (1) r. height width operator area = 3.14 * r *r + width * height literal/constant variable expression (assignment) statement 12-2 Highlights (2) r. height
More informationProgramming - 1. Computer Science Department 011COMP-3 لغة البرمجة 1 لطالب كلية الحاسب اآللي ونظم المعلومات 011 عال- 3
Programming - 1 Computer Science Department 011COMP-3 لغة البرمجة 1 011 عال- 3 لطالب كلية الحاسب اآللي ونظم المعلومات 1 1.1 Machine Language A computer programming language which has binary instructions
More informationLESSON 1. A C program is constructed as a sequence of characters. Among the characters that can be used in a program are:
LESSON 1 FUNDAMENTALS OF C The purpose of this lesson is to explain the fundamental elements of the C programming language. C like other languages has all alphabet and rules for putting together words
More informationReview of the C Programming Language
Review of the C Programming Language Prof. James L. Frankel Harvard University Version of 11:55 AM 22-Apr-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights reserved. Reference Manual for the
More informationCOP 2000 Introduction to Computer Programming Mid-Term Exam Review
he exam format will be different from the online quizzes. It will be written on the test paper with questions similar to those shown on the following pages. he exam will be closed book, but students can
More informationInformation Science 1
Information Science 1 Simple Calcula,ons Week 09 College of Information Science and Engineering Ritsumeikan University Topics covered l Terms and concepts from Week 8 l Simple calculations Documenting
More informationCSC 1214: Object-Oriented Programming
CSC 1214: Object-Oriented Programming J. Kizito Makerere University e-mail: jkizito@cis.mak.ac.ug www: http://serval.ug/~jona materials: http://serval.ug/~jona/materials/csc1214 e-learning environment:
More informationCS313D: ADVANCED PROGRAMMING LANGUAGE
CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 2 : C# Language Basics Lecture Contents 2 The C# language First program Variables and constants Input/output Expressions and casting
More informationWriting an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and
Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and #include The Use of printf() and scanf() The Use of printf()
More informationC/Java Syntax. January 13, Slides by Mark Hancock (adapted from notes by Craig Schock)
C/Java Syntax 1 Lecture 02 Summary Keywords Variable Declarations Data Types Operators Statements if, switch, while, do-while, for Functions 2 By the end of this lecture, you will be able to identify the
More informationC/Java Syntax. Lecture 02 Summary. Keywords Variable Declarations Data Types Operators Statements. Functions. if, switch, while, do-while, for
C/Java Syntax 1 Lecture 02 Summary Keywords Variable Declarations Data Types Operators Statements if, switch, while, do-while, for Functions 2 1 By the end of this lecture, you will be able to identify
More informationGuide for The C Programming Language Chapter 1. Q1. Explain the structure of a C program Answer: Structure of the C program is shown below:
Q1. Explain the structure of a C program Structure of the C program is shown below: Preprocessor Directives Global Declarations Int main (void) Local Declarations Statements Other functions as required
More informationCENG 447/547 Embedded and Real-Time Systems. Review of C coding and Soft Eng Concepts
CENG 447/547 Embedded and Real-Time Systems Review of C coding and Soft Eng Concepts Recall (C-style coding syntax) ; - Indicate the end of an expression {} - Used to delineate when a sequence of elements
More informationSir Muhammad Naveed. Arslan Ahmed Shaad ( ) Muhammad Bilal ( )
Sir Muhammad Naveed Arslan Ahmed Shaad (1163135 ) Muhammad Bilal ( 1163122 ) www.techo786.wordpress.com CHAPTER: 2 NOTES:- VARIABLES AND OPERATORS The given Questions can also be attempted as Long Questions.
More informationEngineering Computing I
Engineering Computing I Types, Operators, and Expressions Types Operators Expressions 2 1 2.1 Variable Names Names are made up of letters and digits The first character must be a letter The underscore
More informationArithmetic Operators. Portability: Printing Numbers
Arithmetic Operators Normal binary arithmetic operators: + - * / Modulus or remainder operator: % x%y is the remainder when x is divided by y well defined only when x > 0 and y > 0 Unary operators: - +
More informationISA 563 : Fundamentals of Systems Programming
ISA 563 : Fundamentals of Systems Programming Variables, Primitive Types, Operators, and Expressions September 4 th 2008 Outline Define Expressions Discuss how to represent data in a program variable name
More informationInformatics Ingeniería en Electrónica y Automática Industrial
Informatics Ingeniería en Electrónica y Automática Industrial Operators and expressions in C Operators and expressions in C Numerical expressions and operators Arithmetical operators Relational and logical
More informationI Internal Examination Sept Class: - BCA I Subject: - Principles of Programming Lang. (BCA 104) MM: 40 Set: A Time: 1 ½ Hrs.
I Internal Examination Sept. 2018 Class: - BCA I Subject: - Principles of Programming Lang. (BCA 104) MM: 40 Set: A Time: 1 ½ Hrs. [I]Very short answer questions (Max 40 words). (5 * 2 = 10) 1. What is
More informationObject oriented programming. Instructor: Masoud Asghari Web page: Ch: 3
Object oriented programming Instructor: Masoud Asghari Web page: http://www.masses.ir/lectures/oops2017sut Ch: 3 1 In this slide We follow: https://docs.oracle.com/javase/tutorial/index.html Trail: Learning
More informationWeek 4 Lecture 1. Expressions and Functions
Lecture 1 Expressions and Functions Expressions A representation of a value Expressions have a type Expressions have a value Examples 1 + 2: type int; value 3 1.2 + 3: type float; value 4.2 2 More expression
More informationExpressions and Data Types CSC 121 Spring 2015 Howard Rosenthal
Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types
More informationProgramming in C and Data Structures [15PCD13/23] 1. PROGRAMMING IN C AND DATA STRUCTURES [As per Choice Based Credit System (CBCS) scheme]
Programming in C and Data Structures [15PCD13/23] 1 PROGRAMMING IN C AND DATA STRUCTURES [As per Choice Based Credit System (CBCS) scheme] Course objectives: The objectives of this course is to make students
More informationArduino Uno. Power & Interface. Arduino Part 1. Introductory Medical Device Prototyping. Digital I/O Pins. Reset Button. USB Interface.
Introductory Medical Device Prototyping Arduino Part 1, http://saliterman.umn.edu/ Department of Biomedical Engineering, University of Minnesota Arduino Uno Power & Interface Reset Button USB Interface
More informationCP FAQS Q-1) Define flowchart and explain Various symbols of flowchart Q-2) Explain basic structure of c language Documentation section :
CP FAQS Q-1) Define flowchart and explain Various symbols of flowchart ANS. Flowchart:- A diagrametic reperesentation of program is known as flowchart Symbols Q-2) Explain basic structure of c language
More informationWhy embedded systems?
MSP430 Intro Why embedded systems? Big bang-for-the-buck by adding some intelligence to systems. Embedded Systems are ubiquitous. Embedded Systems more common as prices drop, and power decreases. Which
More informationChapter 12 Variables and Operators
Chapter 12 Variables and Operators Basic C Elements Variables Named, typed data items Operators Predefined actions performed on data items Combined with variables to form expressions, statements Statements
More informationOperators in java Operator operands.
Operators in java Operator in java is a symbol that is used to perform operations and the objects of operation are referred as operands. There are many types of operators in java such as unary operator,
More informationProgramming. Elementary Concepts
Programming Elementary Concepts Summary } C Language Basic Concepts } Comments, Preprocessor, Main } Key Definitions } Datatypes } Variables } Constants } Operators } Conditional expressions } Type conversions
More informationLecture 02 Summary. C/Java Syntax 1/14/2009. Keywords Variable Declarations Data Types Operators Statements. Functions
Lecture 02 Summary C/Java Syntax Keywords Variable Declarations Data Types Operators Statements if, switch, while, do-while, for Functions 1 2 By the end of this lecture, you will be able to identify the
More informationC Programming Language
C Programming Language Advantages over assembly language for microcontrollers: More portable Math functions Readability Maintainability Editing C End-of-line ignored Use line breaks/tabs/indent for readability
More informationC: How to Program. Week /Mar/05
1 C: How to Program Week 2 2007/Mar/05 Chapter 2 - Introduction to C Programming 2 Outline 2.1 Introduction 2.2 A Simple C Program: Printing a Line of Text 2.3 Another Simple C Program: Adding Two Integers
More informationObjects and Types. COMS W1007 Introduction to Computer Science. Christopher Conway 29 May 2003
Objects and Types COMS W1007 Introduction to Computer Science Christopher Conway 29 May 2003 Java Programs A Java program contains at least one class definition. public class Hello { public static void
More informationA Java program contains at least one class definition.
Java Programs Identifiers Objects and Types COMS W1007 Introduction to Computer Science Christopher Conway 29 May 2003 A Java program contains at least one class definition. public class Hello { public
More informationOperators. Lecture 12 Section Robb T. Koether. Hampden-Sydney College. Fri, Feb 9, 2018
Operators Lecture 12 Section 14.5 Robb T. Koether Hampden-Sydney College Fri, Feb 9, 2018 Robb T. Koether (Hampden-Sydney College) Operators Fri, Feb 9, 2018 1 / 21 Outline 1 Operators as Functions 2 Operator
More informationCreating a C++ Program
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer. 1 Creating a C++ Program created using an
More informationVariables and literals
Demo lecture slides Although I will not usually give slides for demo lectures, the first two demo lectures involve practice with things which you should really know from G51PRG Since I covered much of
More informationCSc 10200! Introduction to Computing. Lecture 2-3 Edgardo Molina Fall 2013 City College of New York
CSc 10200! Introduction to Computing Lecture 2-3 Edgardo Molina Fall 2013 City College of New York 1 C++ for Engineers and Scientists Third Edition Chapter 2 Problem Solving Using C++ 2 Objectives In this
More informationC Language Part 1 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee
C Language Part 1 (Minor modifications by the instructor) References C for Python Programmers, by Carl Burch, 2011. http://www.toves.org/books/cpy/ The C Programming Language. 2nd ed., Kernighan, Brian,
More informationControl Structures. Lecture 4 COP 3014 Fall September 18, 2017
Control Structures Lecture 4 COP 3014 Fall 2017 September 18, 2017 Control Flow Control flow refers to the specification of the order in which the individual statements, instructions or function calls
More information