C Language Summary. Chris J Michael 28 August CSC 4103 Operating Systems Fall 2008 Lecture 2 C Summary
|
|
- Stanley Hunt
- 6 years ago
- Views:
Transcription
1 Chris J Michael cmicha1@lsu.edu 28 August 2008 C Language Summary Heavily Influenced by the GNU C Reference Manual:
2 Introduction -C98, or the original ANSI C standard -Lower level than C++ & Java -gcc: The GNU C compiler 2
3 Hello World #include <stdio.h> int main(void) { printf("hello World\n"); } return 0; $ gcc hello.c -o hello.out $./hello.out Hello World $ _ 3
4 Hello World #include <stdio.h> int main(void) { printf("hello World\n"); } return 0; Whitespace is ignored #include <stdio.h> int main(void){printf("hello World\n");return 0;} 4
5 Hello World #include <stdio.h> int main(void) { printf("hello World\n"); } return 0; Include the library that provides printing functions 5
6 Hello World #include <stdio.h> int main(void) { printf("hello World\n"); } return 0; Every C program must have a main function int main(void) The main function returns an integer value. It must be named main. In this case, it does not receive any parameters. 6
7 Hello World #include <stdio.h> int main(void) { printf("hello World\n"); } return 0; The scope encloses the function body 7
8 Hello World #include <stdio.h> int main(void) { printf("hello World\n"); } return 0; Call the print function with the desired argument printf("hello World\n"); Call the function printf Send it the string to print End statements with a semicolon 8
9 Hello World #include <stdio.h> int main(void) { printf("hello World\n"); } return 0; Call the print function with the desired argument printf("hello World\n"); Strings literalsare enclosed in double-quotes. \n represents a new line 9
10 Hello World #include <stdio.h> int main(void) { printf("hello World\n"); } return 0; Since main is defined to return an integer usually a zero is returned 10
11 Identifiers -Used to name variables, functions, and userdefined data types -A group of letters, decimal digits, _ -Cannot start with a number -Examples: foo my_var a1 Something_Clever_1 x C is case-sensitive! 11
12 Constants -Integer Constants: Octal Hexidecimal Equivalent -Character Constants: Enclosed in single-quotes -Real Number Constants: -String Constants: "It s a trap." "It s a" "It s\ a trap." x1f1f \ 'c' 'X' '\n' '\'' '\\' '\"' e9 3e-5 " trap." "It s\na\ntrap." "\"It s a trap\"" It s a trap. It s a trap. Exponent 12
13 Constants -Integer Constants: Octal Hexidecimal Equivalent -Character Constants: Enclosed in single-quotes -Real Number Constants: -String Constants: "It s a trap." "It s a" "It s\ a trap." x1f1f \ 'c' 'X' '\n' '\'' '\\' '\"' e9 3e-5 " trap." "It s\na\ntrap." "\"It s a trap\"" It s a trap. It s a trap. Exponent 13
14 Primitive Data Types Sizes may change from system to system! -Integer types unsigned char /* Holds a value from 0 to 256 */ signed char /* Holds a value from -127 to 128 */ char -Real number types /* May either be unsigned char or signed car depending on the system. This type should be used for character constants. */ int /* Holds a value from -2,147,483,648 to 2,147,483,647 */ unsigned int /* Holds a value from to 4,294,967,647 */ float /* Single precision floating point */ double /* Double */ Enclose comments in these 14
15 Enumeration Definitions -Used to name integer values enum operating_system { BSD, /* The value of BSD will be 0 */ LINUX, /* LINUX will be 1, etc. */ MS_WIN, DOS, TOS }; Naming is optional enum { SLACKWARE=23, /* Here we set the first item to */ FEDORA, /* so FEDORA will be 24, etc. */ GENTOO, DEBIAN }; 15
16 Structure Definitions -A programmer defined type made of variables and other data types. struct particle { int x, y, z; float velocity_x; float velocity_y; float velocity_z; }; You should provide a name Members are declared like variables are normally declared 16
17 -At definition struct particle { int x, y, z; float velocity_x; float velocity_y; float velocity_z; } particle_a, particle_b; -After definition struct particle { int x, y, z; float velocity_x; float velocity_y; float velocity_z; };... Structure Declarations This way is usually preferred struct particle particle_a, particle_b; 17
18 Structure Member Access -Use the member access operator, the '.' struct particle { int x, y, z; float velocity_x; float velocity_y; float velocity_z; };... struct particle particle_a, particle_b; particle_a.x = 4; particle_a.y = -4; particle_a.z = 1; particle_a.velocity_x = 1.0; particle_a.velocity_y = 12e3; particle_a.velocity_z = 0; 18
19 Structure Member Access -Of course, structures may contain other structures struct point { int x, y, z; }; struct velocity { float x, y, z; }; struct particle { struct point p; struct velocity v; };... struct particle particle_a; particle_a.p.x = 4; particle_a.v.x = 1.0; 19
20 Array Declarations and Access -Specify type and amount when declaring Multidimensional, 10x10 array int my_int_array[10]; struct particle particles[10][10]; -Specify array element when accessing my_int_array[0] = 9; /* The first element */ my_int_array[9] = 46; /* The last element */ particles[3][7].p.x = 4; This structure was defined in the last slide Careful not to overstep array boundaries! The compiler may not warn you about this! my_int_array[10] = 6; my_int_array[-1] = 0; 20
21 Strings -Strings are just arrays of characters char my_string[20] = "Hello World"; Initialization H e l l o W o r l d \0 my_string[5] = '\0'; The null character Hello World H e l l o \0 W o r l d \0 Hello You cannot assign string literals after initialization! my_string = "Hello World"; But don't worry! There are some library functions that help us copy string literals into arrays. More on that later. 21
22 Strings -Strings are just arrays of characters char my_string[20] = "Hello World"; Initialization H e l l o W o r l d \0 my_string[5] = '\0'; The null character Hello World H e l l o \0 W o r l d \0 Hello You cannot assign string literals after initialization! my_string = "Hello World"; But don't worry! There are some library functions that help us copy string literals into arrays. More on that later. 22
23 Strings -Strings are just arrays of characters char my_string[20] = "Hello World"; Initialization H e l l o W o r l d \0 my_string[5] = '\0'; The null character Hello World H e l l o \0 W o r l d \0 Hello You cannot assign string literals after initialization! my_string = "Hello World"; But don't worry! There are some library functions that help us copy string literals into arrays. More on that later. 23
24 Pointers There is nothing difficult here, just keep the basics in mind. 24
25 Pointers -Pointers hold memory addresses of stored variables -You can create a pointer for any data type. -The two basic operators: Indirection Address 25
26 Pointers These are the contents of the memory locations -Keep the memory model in mind These are addresses of the memory locations The denotes uninitialized or junk data in memory 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 26
27 Pointer Declarations -To declare a pointer of any type, simply use the indirection operator before the 0x00 identifier int *p_to_int; float *p_to_f1, *p_to_f2; -Use caution when declaring multiple pointers at once int *p1, *p2, i1; These are pointers This is an integer 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 27
28 Pointer Access -Use the address operator to set a pointer int i = 0; /* Will be located at 0x05 */ int j = 1; /* Will be located at 0x07 */ int *p = &i; /* Will be located at 0x09 */ 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 28
29 Pointer Access -Use the address operator to set a pointer int i = 0; /* Will be located at 0x05 */ int j = 1; /* Will be located at 0x07 */ int *p = &i; /* Will be located at 0x09 */ 0x00 0x01 0x02 0x03 0x04 0x05 0 0x06 0x07 0x08 0x09 29
30 Pointer Access -Use the address operator to set a pointer int i = 0; /* Will be located at 0x05 */ int j = 1; /* Will be located at 0x07 */ int *p = &i; /* Will be located at 0x09 */ 0x00 0x01 0x02 0x03 0x04 0x05 0 0x06 0x07 1 0x08 0x09 30
31 Pointer Access -Use the address operator to set a pointer int i = 0; /* Will be located at 0x05 */ int j = 1; /* Will be located at 0x07 */ int *p = &i; /* Will be located at 0x09 */ 0x00 0x01 0x02 0x03 0x04 0x05 0 0x06 0x07 1 0x08 0x09 0x05 31
32 Pointer Access -Use the address operator to set a pointer int i = 0; /* Will be located at 0x05 */ int j = 1; /* Will be located at 0x07 */ int *p = &i; /* Will be located at 0x09 */ Don't let this initialization confuse you. All we're really doing is int *p;... p = &i; 0x00 0x01 0x02 0x03 0x04 0x05 0 0x06 0x07 1 0x08 0x09 0x05 32
33 Pointer Access -Use the address operator to set a pointer int i = 0; /* Will be located at 0x05 */ int j = 1; /* Will be located at 0x07 */ int *p = &i; /* Will be located at 0x09 */ *p = 4; p = &j; *p = 7; i = *p; 0x00 0x01 0x02 0x03 0x04 0x05 0 0x06 0x07 1 0x08 0x09 0x05 33
34 Pointer Access -Use the address operator to set a pointer int i = 0; /* Will be located at 0x05 */ int j = 1; /* Will be located at 0x07 */ int *p = &i; /* Will be located at 0x09 */ *p = 4; p = &j; *p = 7; i = *p; 0x00 0x01 0x02 0x03 0x04 0x05 4 0x06 0x07 1 0x08 0x09 0x05 34
35 Pointer Access -Use the address operator to set a pointer int i = 0; /* Will be located at 0x05 */ int j = 1; /* Will be located at 0x07 */ int *p = &i; /* Will be located at 0x09 */ *p = 4; p = &j; *p = 7; i = *p; 0x00 0x01 0x02 0x03 0x04 0x05 4 0x06 0x07 1 0x08 0x09 0x07 35
36 Pointer Access -Use the address operator to set a pointer int i = 0; /* Will be located at 0x05 */ int j = 1; /* Will be located at 0x07 */ int *p = &i; /* Will be located at 0x09 */ *p = 4; p = &j; *p = 7; i = *p; 0x00 0x01 0x02 0x03 0x04 0x05 4 0x06 0x07 7 0x08 0x09 0x07 36
37 Pointer Access -Use the address operator to set a pointer int i = 0; /* Will be located at 0x05 */ int j = 1; /* Will be located at 0x07 */ int *p = &i; /* Will be located at 0x09 */ *p = 4; p = &j; *p = 7; i = *p; This is called a dereference, it obtains the value stored at the memory location the pointer holds 0x00 0x01 0x02 0x03 0x04 0x05 7 0x06 0x07 7 0x08 0x09 0x07 37
38 -Similar concept Pointers to Structures struct loc { int x, y, z; }; struct loc l; /* Will start at 0x02 */ struct loc *p; /* Will be at 0x08 */ l.x = 0; l.y = 1; l.z = 0; p = &l 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 38
39 -Similar concept Pointers to Structures struct loc { int x, y, z; }; struct loc l; /* Will start at 0x02 */ struct loc *p; /* Will be at 0x08 */ l.x = 0; l.y = 1; l.z = 0; p = &l 0x00 0x01 0x02 0 0x03 1 0x04 0 0x05 0x06 0x07 0x08 0x09 39
40 -Similar concept Pointers to Structures struct loc { int x, y, z; }; struct loc l; /* Will start at 0x02 */ struct loc *p; /* Will be at 0x08 */ l.x = 0; l.y = 1; l.z = 0; p = &l 0x00 0x01 0x02 0 0x03 1 0x04 0 0x05 0x06 0x07 0x08 0x02 0x09 40
41 -Similar concept Pointers to Structures struct loc { int x, y, z; }; struct loc l; /* Will start at 0x02 */ struct loc *p; /* Will be at 0x08 */ l.x = 0; l.y = 1; l.z = 0; p = &l p->x = 2; p->y = 4; Indirect member access operator 0x00 0x01 0x02 0 0x03 1 0x04 0 0x05 0x06 0x07 0x08 0x02 0x09 41
42 -Similar concept Pointers to Structures struct loc { int x, y, z; }; struct loc l; /* Will start at 0x02 */ struct loc *p; /* Will be at 0x08 */ l.x = 0; l.y = 1; l.z = 0; p = &l p->x = 2; p->y = 4; 0x00 0x01 0x02 2 0x03 1 0x04 0 0x05 0x06 0x07 0x08 0x02 0x09 42
43 -Similar concept Pointers to Structures struct loc { int x, y, z; }; struct loc l; /* Will start at 0x02 */ struct loc *p; /* Will be at 0x08 */ l.x = 0; l.y = 1; l.z = 0; p = &l p->x = 2; p->y = 4; p->y is the same as (*p).y 0x00 0x01 0x02 2 0x03 4 0x04 0 0x05 0x06 0x07 0x08 0x02 0x09 43
44 -Similar concept Pointers to Structures struct loc { int x, y, z; }; struct loc l; /* Will start at 0x02 */ struct loc *p; /* Will be at 0x08 */ l.x = 0; l.y = 1; l.z = 0; p = &l p->x = 2; p->y = 4; l.x = p->z; 0x00 0x01 0x02 2 0x03 4 0x04 0 0x05 0x06 0x07 0x08 0x02 0x09 44
45 -Similar concept Pointers to Structures struct loc { int x, y, z; }; struct loc l; /* Will start at 0x02 */ struct loc *p; /* Will be at 0x08 */ l.x = 0; l.y = 1; l.z = 0; p = &l p->x = 2; p->y = 4; l.x = p->z; 0x00 0x01 0x02 0 0x03 4 0x04 0 0x05 0x06 0x07 0x08 0x02 0x09 45
46 Type and Storage Specifiers -Common Type Specifier: const const float pi = ; pi is declared as read only -Common Storage Specifier: extern extern int seconds;... Must have an "extern" and "non-extern" declaration int seconds = 3600; seconds is visible to all files linked the your project 46
47 Expressions -An expression is one operand and zero or more operators 13 constants may be operands addition operator calculate_sum(1, 1) functions with return values may be operands (8 * (12 + 4)) use parentheses to group expressions -- innermost expressions are evaluated first 47
48 Unary Operators Increment: ++x x++ Decrement: --x x-- Positive: +x Negative: -x Logical Negation:!x Bitwise Negation: ~x Address: &x Indirection: *x Size of: sizeof(x) Type casting: (int)x (float)x (type)x Array Subscript: x[3] 48
49 Binary Operators Addition: x + y Subtraction: x - y Multiplication: x * y Be careful about types Division: x / y Modulus: x % y Bit shift: x << y Bitwise AND: x & y Bitwise OR: x y Bitwise XOR: x ^ y Comparison: x == y x!= y x < y x <= y x > y x >= y Logical: x && y x y Assignment: x = y Compound Assignment: x += y x -= y x *= y x /= y etc. 49
50 Binary Operators Comma: x, y Member Access: x.y x->y The Ternary Operator x? y : z 50
51 Next Time -A closer look at the highlighted operators -Statements: actions and control flow -Functions -Program structure -Helpful code snippets 51
52 52
Expressions 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 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 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 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 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 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 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 informationWork relative to other classes
Work relative to other classes 1 Hours/week on projects 2 C BOOTCAMP DAY 1 CS3600, Northeastern University Slides adapted from Anandha Gopalan s CS132 course at Univ. of Pittsburgh Overview C: A language
More informationC Language Summary (Continued)
Chris J Michael cmicha1@lsu.edu 11 September 2008 C Language Summary (Continued) Heavily Influenced by the GNU C Reference Manual: http://www.gnu.org/software/gnu-c-manual/ Q/A -Somebody brought up a nice
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 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
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 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 informationOperators. Lecture 3 COP 3014 Spring January 16, 2018
Operators Lecture 3 COP 3014 Spring 2018 January 16, 2018 Operators Special built-in symbols that have functionality, and work on operands operand an input to an operator Arity - how many operands an operator
More informationC OVERVIEW. C Overview. Goals speed portability allow access to features of the architecture speed
C Overview C OVERVIEW Goals speed portability allow access to features of the architecture speed C fast executables allows high-level structure without losing access to machine features many popular languages
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 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 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 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 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 informationOBJECT ORIENTED PROGRAMMING
OBJECT ORIENTED PROGRAMMING LAB 1 REVIEW THE STRUCTURE OF A C/C++ PROGRAM. TESTING PROGRAMMING SKILLS. COMPARISON BETWEEN PROCEDURAL PROGRAMMING AND OBJECT ORIENTED PROGRAMMING Course basics The Object
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 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 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 informationCS 61C: Great Ideas in Computer Architecture Introduction to C
CS 61C: Great Ideas in Computer Architecture Introduction to C Instructors: Vladimir Stojanovic & Nicholas Weaver http://inst.eecs.berkeley.edu/~cs61c/ 1 Agenda C vs. Java vs. Python Quick Start Introduction
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 informationC OVERVIEW BASIC C PROGRAM STRUCTURE. C Overview. Basic C Program Structure
C Overview Basic C Program Structure C OVERVIEW BASIC C PROGRAM STRUCTURE Goals The function main( )is found in every C program and is where every C program begins speed execution portability C uses braces
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 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 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 informationCSE 1001 Fundamentals of Software Development 1. Identifiers, Variables, and Data Types Dr. H. Crawford Fall 2018
CSE 1001 Fundamentals of Software Development 1 Identifiers, Variables, and Data Types Dr. H. Crawford Fall 2018 Identifiers, Variables and Data Types Reserved Words Identifiers in C Variables and Values
More informationIntroduction to C Language
Introduction to C Language Instructor: Professor I. Charles Ume ME 6405 Introduction to Mechatronics Fall 2006 Instructor: Professor Charles Ume Introduction to C Language History of C Language In 1972,
More informationLECTURE 3 C++ Basics Part 2
LECTURE 3 C++ Basics Part 2 OVERVIEW Operators Type Conversions OPERATORS Operators are special built-in symbols that have functionality, and work on operands. Operators are actually functions that use
More informationRoom 3P16 Telephone: extension ~irjohnson/uqc146s1.html
UQC146S1 Introductory Image Processing in C Ian Johnson Room 3P16 Telephone: extension 3167 Email: Ian.Johnson@uwe.ac.uk http://www.csm.uwe.ac.uk/ ~irjohnson/uqc146s1.html Ian Johnson 1 UQC146S1 What is
More informationLEXICAL 2 CONVENTIONS
LEXIAL 2 ONVENTIONS hapter SYS-ED/ OMPUTER EDUATION TEHNIQUES, IN. ++ Programming Lexical onventions Objectives You will learn: Operators. Punctuators. omments. Identifiers. Literals. SYS-ED \OMPUTER EDUATION
More informationCSC 1107: Structured Programming
CSC 1107: Structured Programming J. Kizito Makerere University e-mail: www: materials: e-learning environment: office: alt. office: jkizito@cis.mak.ac.ug http://serval.ug/~jona http://serval.ug/~jona/materials/csc1107
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 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 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 informationProgramming in C and C++
Programming in C and C++ Types, Variables, Expressions and Statements Neel Krishnaswami and Alan Mycroft Course Structure Basics of C: Types, variables, expressions and statements Functions, compilation
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 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 informationVariables and Operators 2/20/01 Lecture #
Variables and Operators 2/20/01 Lecture #6 16.070 Variables, their characteristics and their uses Operators, their characteristics and their uses Fesq, 2/20/01 1 16.070 Variables Variables enable you to
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 informationRecap. ANSI C Reserved Words C++ Multimedia Programming Lecture 2. Erwin M. Bakker Joachim Rijsdam
Multimedia Programming 2004 Lecture 2 Erwin M. Bakker Joachim Rijsdam Recap Learning C++ by example No groups: everybody should experience developing and programming in C++! Assignments will determine
More informationChapter 2: Introduction to C++
Chapter 2: Introduction to C++ Copyright 2010 Pearson Education, Inc. Copyright Publishing as 2010 Pearson Pearson Addison-Wesley Education, Inc. Publishing as Pearson Addison-Wesley 2.1 Parts of a C++
More informationChapter 2: Special Characters. Parts of a C++ Program. Introduction to C++ Displays output on the computer screen
Chapter 2: Introduction to C++ 2.1 Parts of a C++ Program Copyright 2009 Pearson Education, Inc. Copyright 2009 Publishing Pearson as Pearson Education, Addison-Wesley Inc. Publishing as Pearson Addison-Wesley
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 informationReserved Words and Identifiers
1 Programming in C Reserved Words and Identifiers Reserved word Word that has a specific meaning in C Ex: int, return Identifier Word used to name and refer to a data element or object manipulated by the
More informationMain Program. C Programming Notes. #include <stdio.h> main() { printf( Hello ); } Comments: /* comment */ //comment. Dr. Karne Towson University
C Programming Notes Dr. Karne Towson University Reference for C http://www.cplusplus.com/reference/ Main Program #include main() printf( Hello ); Comments: /* comment */ //comment 1 Data Types
More informationLanguage Reference Manual simplicity
Language Reference Manual simplicity Course: COMS S4115 Professor: Dr. Stephen Edwards TA: Graham Gobieski Date: July 20, 2016 Group members Rui Gu rg2970 Adam Hadar anh2130 Zachary Moffitt znm2104 Suzanna
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 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 informationC - Basics, Bitwise Operator. Zhaoguo Wang
C - Basics, Bitwise Operator Zhaoguo Wang Java is the best language!!! NO! C is the best!!!! Languages C Java Python 1972 1995 2000 (2.0) Procedure Object oriented Procedure & object oriented Compiled
More informationC Syntax Out: 15 September, 1995
Burt Rosenberg Math 220/317: Programming II/Data Structures 1 C Syntax Out: 15 September, 1995 Constants. Integer such as 1, 0, 14, 0x0A. Characters such as A, B, \0. Strings such as "Hello World!\n",
More informationTED Language Reference Manual
1 TED Language Reference Manual Theodore Ahlfeld(twa2108), Konstantin Itskov(koi2104) Matthew Haigh(mlh2196), Gideon Mendels(gm2597) Preface 1. Lexical Elements 1.1 Identifiers 1.2 Keywords 1.3 Constants
More informationA Fast Review of C Essentials Part I
A Fast Review of C Essentials Part I Structural Programming by Z. Cihan TAYSI Outline Program development C Essentials Functions Variables & constants Names Formatting Comments Preprocessor Data types
More informationANSI C Programming Simple Programs
ANSI C Programming Simple Programs /* This program computes the distance between two points */ #include #include #include main() { /* Declare and initialize variables */ double
More informationDifferentiate Between Keywords and Identifiers
History of C? Why we use C programming language Martin Richards developed a high-level computer language called BCPL in the year 1967. The intention was to develop a language for writing an operating system(os)
More informationTypescript on LLVM Language Reference Manual
Typescript on LLVM Language Reference Manual Ratheet Pandya UNI: rp2707 COMS 4115 H01 (CVN) 1. Introduction 2. Lexical Conventions 2.1 Tokens 2.2 Comments 2.3 Identifiers 2.4 Reserved Keywords 2.5 String
More informationLanguage Fundamentals Summary
Language Fundamentals Summary Claudia Niederée, Joachim W. Schmidt, Michael Skusa Software Systems Institute Object-oriented Analysis and Design 1999/2000 c.niederee@tu-harburg.de http://www.sts.tu-harburg.de
More informationCSCI 2132: Software Development. Norbert Zeh. Faculty of Computer Science Dalhousie University. Introduction to C. Winter 2019
CSCI 2132: Software Development Introduction to C Norbert Zeh Faculty of Computer Science Dalhousie University Winter 2019 The C Programming Language Originally invented for writing OS and other system
More informationC-Programming. CSC209: Software Tools and Systems Programming. Paul Vrbik. University of Toronto Mississauga
C-Programming CSC209: Software Tools and Systems Programming Paul Vrbik University of Toronto Mississauga https://mcs.utm.utoronto.ca/~209/ Adapted from Dan Zingaro s 2015 slides. Week 2.0 1 / 19 What
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 informationLECTURE 02 INTRODUCTION TO C++
PowerPoint Slides adapted from *Starting Out with C++: From Control Structures through Objects, 7/E* by *Tony Gaddis* Copyright 2012 Pearson Education Inc. COMPUTER PROGRAMMING LECTURE 02 INTRODUCTION
More informationOperators. 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 informationProgramming in C++ 6. Floating point data types
Programming in C++ 6. Floating point data types! Introduction! Type double! Type float! Changing types! Type promotion & conversion! Casts! Initialization! Assignment operators! Summary 1 Introduction
More informationLesson 3 Introduction to Programming in C
jgromero@inf.uc3m.es Lesson 3 Introduction to Programming in C Programming Grade in Industrial Technology Engineering This work is licensed under a Creative Commons Reconocimiento-NoComercial-CompartirIgual
More informationComputer Science & Information Technology (CS) Rank under AIR 100. Examination Oriented Theory, Practice Set Key concepts, Analysis & Summary
GATE- 2016-17 Postal Correspondence 1 C-Programming Computer Science & Information Technology (CS) 20 Rank under AIR 100 Postal Correspondence Examination Oriented Theory, Practice Set Key concepts, Analysis
More informationCHAPTER 3 BASIC INSTRUCTION OF C++
CHAPTER 3 BASIC INSTRUCTION OF C++ MOHD HATTA BIN HJ MOHAMED ALI Computer programming (BFC 20802) Subtopics 2 Parts of a C++ Program Classes and Objects The #include Directive Variables and Literals Identifiers
More informationThe C++ Language. Arizona State University 1
The C++ Language CSE100 Principles of Programming with C++ (based off Chapter 2 slides by Pearson) Ryan Dougherty Arizona State University http://www.public.asu.edu/~redoughe/ Arizona State University
More informationEL2310 Scientific Programming
(yaseminb@kth.se) Overview Overview Roots of C Getting started with C Closer look at Hello World Programming Environment Discussion Basic Datatypes and printf Schedule Introduction to C - main part of
More informationBASIC ELEMENTS OF A COMPUTER PROGRAM
BASIC ELEMENTS OF A COMPUTER PROGRAM CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING LOGO Contents 1 Identifier 2 3 Rules for naming and declaring data variables Basic data types 4 Arithmetic operators
More informationLecture 05 I/O statements Printf, Scanf Simple statements, Compound statements
Programming, Data Structures and Algorithms Prof. Shankar Balachandran Department of Computer Science and Engineering Indian Institute of Technology, Madras Lecture 05 I/O statements Printf, Scanf Simple
More informationTypes, Operators and Expressions
Types, Operators and Expressions EECS 2031 18 September 2017 1 Variable Names (2.1) l Combinations of letters, numbers, and underscore character ( _ ) that do not start with a number; are not a keyword.
More informationJAVA Programming Fundamentals
Chapter 4 JAVA Programming Fundamentals By: Deepak Bhinde PGT Comp.Sc. JAVA character set Character set is a set of valid characters that a language can recognize. It may be any letter, digit or any symbol
More informationBasics of Java Programming
Basics of Java Programming Lecture 2 COP 3252 Summer 2017 May 16, 2017 Components of a Java Program statements - A statement is some action or sequence of actions, given as a command in code. A statement
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 informationStructure of this course. C and C++ Past Exam Questions. Text books
Structure of this course C and C++ 1. Types Variables Expressions & Statements Alastair R. Beresford University of Cambridge Lent Term 2008 Programming in C: types, variables, expressions & statements
More information(heavily based on last year s notes (Andrew Moore) with thanks to Alastair R. Beresford. 1. Types Variables Expressions & Statements 2/23
Structure of this course Programming in C: types, variables, expressions & statements functions, compilation, pre-processor pointers, structures extended examples, tick hints n tips Programming in C++:
More informationJAC444 - Lecture 1. Introduction to Java Programming Language Segment 4. Jordan Anastasiade Java Programming Language Course
JAC444 - Lecture 1 Introduction to Java Programming Language Segment 4 1 Overview of the Java Language In this segment you will be learning about: Numeric Operators in Java Type Conversion If, For, While,
More informationVariables Data types Variable I/O. C introduction. Variables. Variables 1 / 14
C introduction Variables Variables 1 / 14 Contents Variables Data types Variable I/O Variables 2 / 14 Usage Declaration: t y p e i d e n t i f i e r ; Assignment: i d e n t i f i e r = v a l u e ; Definition
More informationCS113: Lecture 3. Topics: Variables. Data types. Arithmetic and Bitwise Operators. Order of Evaluation
CS113: Lecture 3 Topics: Variables Data types Arithmetic and Bitwise Operators Order of Evaluation 1 Variables Names of variables: Composed of letters, digits, and the underscore ( ) character. (NO spaces;
More informationCS Programming In C
CS 24000 - Programming In C Week Two: Basic C Program Organization and Data Types Zhiyuan Li Department of Computer Science Purdue University, USA 2 int main() { } return 0; The Simplest C Program C programs
More informationPresented By : Gaurav Juneja
Presented By : Gaurav Juneja Introduction C is a general purpose language which is very closely associated with UNIX for which it was developed in Bell Laboratories. Most of the programs of UNIX are written
More informationJava Basic Programming Constructs
Java Basic Programming Constructs /* * This is your first java program. */ class HelloWorld{ public static void main(string[] args){ System.out.println( Hello World! ); A Closer Look at HelloWorld 2 This
More informationC Programming Language. Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff
C Programming Language 1 C C is better to use than assembly for embedded systems programming. You can program at a higher level of logic than in assembly, so programs are shorter and easier to understand.
More informationChapter 2. Lexical Elements & Operators
Chapter 2. Lexical Elements & Operators Byoung-Tak Zhang TA: Hanock Kwak Biointelligence Laboratory School of Computer Science and Engineering Seoul National Univertisy http://bi.snu.ac.kr The C System
More informationReview: Exam 1. Your First C++ Program. Declaration Statements. Tells the compiler. Examples of declaration statements
Review: Exam 1 9/20/06 CS150 Introduction to Computer Science 1 1 Your First C++ Program 1 //*********************************************************** 2 // File name: hello.cpp 3 // Author: Shereen Khoja
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 informationDeclaration and Memory
Declaration and Memory With the declaration int width; the compiler will set aside a 4-byte (32-bit) block of memory (see right) The compiler has a symbol table, which will have an entry such as Identifier
More informationTypes, Operators and Expressions
Types, Operators and Expressions CSE 2031 Fall 2011 9/11/2011 5:24 PM 1 Variable Names (2.1) Combinations of letters, numbers, and underscore character ( _ ) that do not start with a number; are not a
More informationChapter 3 Structure of a C Program
Chapter 3 Structure of a C Program Objectives To be able to list and describe the six expression categories To understand the rules of precedence and associativity in evaluating expressions To understand
More informationI2204 ImperativeProgramming Semester: 1 Academic Year: 2018/2019 Credits: 5 Dr Antoun Yaacoub
Lebanese University Faculty of Science Computer Science BS Degree I2204 ImperativeProgramming Semester: 1 Academic Year: 2018/2019 Credits: 5 Dr Antoun Yaacoub 2Computer Science BS Degree -Imperative Programming
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 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 informationWe do not teach programming
We do not teach programming We do not teach C Take a course Read a book The C Programming Language, Kernighan, Richie Georgios Georgiadis Negin F.Nejad This is a brief tutorial on C s traps and pitfalls
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 information