EEE-425 Programming Languages (2013) 1
|
|
- Scott Richards
- 6 years ago
- Views:
Transcription
1 2 Namespaces Classes Fields Properties Methods Attributes Events Interfaces (contracts) Methods Properties Events Control Statements if, else, while, for, switch foreach Additional Features Operation Overloading Structs Enums Delegates OO Features Type Unification Inheritance Polymorphism Namespaces Contain types and other namespaces Type declarations Classes, struct s, interfaces, enum s, and delegates Contain members Members Constants, fields, methods, operators, constructors, destructors Properties, indexers, events Organization No header files, types imported using assemblies (dll s). Type reflection 3 4 C# predefined types The root object Logical bool Signed sbyte, short, int, long Unsigned byte, ushort, uint, ulong Floating-point float, double, decimal Textual char, string Textual types use Unicode (16-bit characters) A data item is classified as either constant or variable Constant data items cannot vary Variable data items can hold different values at different points of time All data items in a C# program have a data type Data type describes the format and size of a piece of data 5 6 EEE-425 Programming Languages (2013) 1
2 C# provides 14 basic or intrinsic types The most commonly used data types are: int, double, char, string, and bool Each C# intrinsic type is an alias, or other name for, a class in the System namespace A variable declaration includes: The data type that the variable will store An identifier that is the variable s name An optional assignment operator and assigned value when you want a variable to contain an initial value An ending semicolon 7 8 Examples of variable declarations: int myage = 25; The equal sign (=) is an assignment operator The assignment operator works from right to left An assignment made when a variable is declared is an initialization It is not necessary to initialize a variable during a declaration. For example int myage; is a valid declaration You can display variable values by using the variable name within a WriteLine() method call 9 10 Program that displays a string and a variable value A format string is a string of characters that contains one or more placeholders. For example: Console.WriteLine( The money is 0 exactly, somemoney); EEE-425 Programming Languages (2013) 2
3 The number within the curly braces in the format string must be less than the number of values you list after the format string You do not have to use the positions in order: Console.WriteLine ( The money is 0. $0 is a lot for my age which is 1, somemoney, myage); C# provides you with several shortcut ways to count and accumulate Examples of Shortcuts: +=, -+, *=, /= The prefix and postfix operators can also provide a shorthand way of writing operators Examples of the unary operators: ++val, val++ Besides the prefix and postfix increment operators, you can also use a decrement operator (--) Boolean logic is based on true or false comparisons Boolean variables can hold only one of two values: true or false You can assign values based on the result of comparisons to Boolean variables A floating-point number is one that contains decimal positions C# supports three floating-point data types: float, double, and decimal A double can hold 15 to 16 significant digits of accuracy Floating-point numbers are double by default Standard numeric format strings are strings of characters expressed within double quotation marks that indicate a format for output. For example, F3, where F is the format specifier and 3 is the precision specifier, indicates a fixed point with three significant digits. The format specifier can be one of nine built-in format characters The precision specifier controls the number of significant digits or zeros to the right of the decimal point Format Specifiers EEE-425 Programming Languages (2013) 3
4 In arithmetic operations with variables or constants of the same type, the result of the operation usually retains the same type - For example, an integer type added to another integer type will result in an integer type When an arithmetic operation is performed with dissimilar types, C# chooses a unifying type for the result and implicitly converts the nonconforming operands to the unifying type There are rules followed by C# for implicit numeric conversions When you perform a cast, you explicitly override the unifying type imposed by C# For example: double balance = ; int dollars = (int)balance; A cast involves placing the desired resulting type in parentheses followed by the variable or constant to be cast The char data type is used to hold a single character ( A, b, 9 ) A number can be a character only if it is enclosed in a single quotation mark (char achar = 9; is illegal) You can store any character in a char variable, including escape sequences Characters in C# are represented in Unicode In C# the string data type holds a series of characters Although you can use the == comparison operator with strings that are assigned literal values, you CANNOT use it with strings created through other methods C# recommends that you use the Equals() and Compare() methods to compare strings A string is considered greater than another string when it is greater lexically Program that compares two strings using == Program that compares two strings using Equals() and Compares() EEE-425 Programming Languages (2013) 4
5 A program that allows user input is an interactive program The Console.ReadLine() method accepts user input from the keyboard This method accepts a user s input as a string You must use a Convert() method to convert the input string to the type required SalesTax program InteractiveSalesTax program Strings are first-class immutable objects in C# Behave like a value type Can be indexed like a char array. Has many methods (see System.String) command allows specifying a string literal spanning lines. string s = Hello ; char third = s[2]; string[] split = s.split(third); Classes, including user-defined classes Inherited from System.Object Transparently refers to a memory location Similar to pointers in other languages Other view is that: Everything is a pointer. Can be set to null A a = new A(); A b = a; memory a fields in class A for instance a b 29 Contain the actual value, not the location Inherited from System.ValueType Which is (logically) derived from System.Object. Treated specially by the runtime Need to be boxed in order to get a reference memory 137 a int a = 137; 137 b int b = a; 30 EEE-425 Programming Languages (2013) 5
6 Value types are not indirectly referenced More efficient. Less memory. In order to treat all types uniformly, a value type needs is converted to a reference type. called boxing. Reverse is unboxing memory 137 a int a = 137; object o1 = a; object o2 = o1; // Boxing int b = (int)o2; //Unboxing int o1 b o2 31 using System; namespace InvestigateOfBoxingUnBoxing class TestBoxing static void Main() int i = 123; object o = i; //Boxing i = 456; // i = (int)o; //Unboxing???? Console.WriteLine("Value-type value = 0", i); Console.WriteLine("Object type data value = 0", o); 32 Copy semantics: Polynomial a = new Polynomial(); Polynomial b = a; b.coefficient[0] = 10; Console.WriteLine(a.Coefficient[0]); int a = 1; int b = a; b = 10; Console.WriteLine(a); Copies of value types make a real copy Important for parameter passing Boxing still copies In C++ you could pass a variable by: Value (creating a new copy and passing it) Pointer (passing in the address) Reference (same as pointer, less cluttered syntax). In C# there seems to be some confusion and misinformation on this. The MSDN documentation for ref has this correct. If you were raised on pointers and understand this (which you are not), then it is quite simple. The ref and out keywords indicate that you should pass: Value types address of value type is passed. Reference types address of pointer is passed ref parameters Use the value that is passed in Change the value of a value type passed in Change the instance that a reference type points to. A valid (or initialized) instance or value type must be passed in. Null is a valid value. out parameters Set the value of a value type passed in. Set the instance that a reference type points to. Does not need to be initialized before calling. Compiler forces you to set a value for all possible code paths EEE-425 Programming Languages (2013) 6
7 For variable number of parameters public void f(int x, params char[] ar); call f(1), f(1, s ), f(1, s, f ), f(1, sf.tochararray()); If, else while Must be the last argument in the list for foreach The typical for loop syntax is: for (initialization; test; update) statements; Consists of Initialization statement Boolean test expression Update statement Loop body block The typical foreach loop syntax is: Iteration over a Collection foreach (Type element in collection) statements; Iterates over all elements of a collection The element is the loop variable that takes sequentially all collection values The collection can be list, array or other group of elements of the same type EEE-425 Programming Languages (2013) 7
8 Example of foreach loop: string[] days = new string[] "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ; foreach (String day in days) Console.WriteLine(day); The above loop iterates of the array of days The variable day takes all its values Print all elements of a string[] array: string[] capitals = "Ankara", "Washington", "London", "Paris" ; foreach (string capital in capitals) Console.WriteLine(capital); Live Demo examples switch statements must be expressions that can be statically evaluated. Restricted to primitive types, strings and enums. There is no fall through on switch cases unless the case is an empty case: switch (myemployee.name) case Boss : Console.Writeline( Your fired! ); break; case Henry : case Jane : Console.Writeline( I need a pay raise. ); break; default: Console.Writeline( Busy working. ); break; Several C# statements provide a break in the execution: break jumps out of a while or for loop or a switch statement. continue starts the next iteration of a loop. goto do not use. return returns out of the current method. throw Causes an exception and ends the current try block or method recursively EEE-425 Programming Languages (2013) 8
9 An array is a sequence of elements All elements are of the same type The order of the elements is fixed Has fixed size (Array.Length) Element of an array Array of 5 elements Element index Declaration defines the type of the elements Square brackets [] mean "array" Examples: Declaring array of integers: int[] myintarray; Declaring array of strings: string[] mystringarray; An array is an object (not just a stream of objects). See System.Array. Bounds checking is performed for all access attempts. Declaration similar to Java, but more strict. Type definition: a is a 1D array of int s Instance specifics: a is equal to a 1D array of int s of size 10. int[] a = new int[10]; int[] b = a; int[] c = new int[3] 1,2,3; int[] d = 1,2,3,4; Use the operator new Specify array length Example creating (allocating) array of 5 integers: myintarray = new int[5]; myintarray managed heap (dynamic memory) Creating and initializing can be done together: myintarray = 1, 2, 3, 4, 5; myintarray managed heap (dynamic memory) The new operator is not required when using curly brackets initialization EEE-425 Programming Languages (2013) 9
10 Creating an array that contains the names of the days of the week string[] daysofweek = "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ; Live Demo Accessing Array Elements Read and Modify Elements by Index Array elements are accessed using the square brackets operator [] (indexer) Array indexer takes element s index as parameter The first element has index 0 The last element has index Length-1 Array elements can be retrieved and changed by the [] operator int[] array = new int[] 1, 2, 3, 4, 5; // Get array size int length = array.length; // Declare and create the reversed array int[] reversed = new int[length]; Reading and Printing Arrays on the Console // Initialize the reversed array for (int index = 0; index < length; index++) reversed[length-index-1] = array[index]; EEE-425 Programming Languages (2013) 10
11 First, read from the console the length of the array int n = int.parse(console.readline()); Next, create the array of given size and read its elements in a for loop int[] arr = new int[n]; for (int i=0; i<n; i++) arr[i] = int.parse(console.readline()); 61 Read int array from the console and check if it is symmetric: bool issymmetric = true; for (int i=0; i<(array.length+1)/2; i++) if (array[i]!= array[n-i-1]) issymmetric = false; 62 Process all elements of the array Print each element to the console Separate elements with white space or a new line string[] array = "one", "two", "three"; // Process all elements of the array for (int index = 0; index < array.length; index++) // Print each element on a separate line Console.WriteLine("element[0] = 1, index, array[index]); 63 class MyArray static void Main(string[] args) int [] n = new int[10]; /* n is an array of 10 integers*/ int i, j; for (i = 0; i<10; i++) /*initialize elements of array n*/ n[ i ] = i + 100; for (j = 0; j <10; j++)/*output each array element's value*/ Console.WriteLine("Element[0] = 1", j, n[j]); Console.ReadKey(); 64 Accessing N-dimensional array element: ndimensionalarray[index1,, indexn] Getting element value example: int[,] array = 1, 2, 3, 4 int element11 = array[1, 1]; //element11 = 4 Number of rows Setting element value example: int[,] array = new int[3, 4]; for (int row=0; row<array.getlength(0); row++) for (int col=0; col<array.getlength(1); col++) array[row, col] = row + col; Number of col 65 int rows = int.parse(console.readline()); int columns = int.parse(console.readline()); int[,] matrix = new int[rows, columns]; String inputnumber; for (int row=0; row<rows; row++) for (int column=0; column<cols; column++) Console.Write("matrix[0,1] = ",row, column); inputnumber = Console.ReadLine(); matrix[row, column] = int.parse(inputnumber); 66 EEE-425 Programming Languages (2013) 11
12 Printing a matrix on the console: for (int row=0; row<matrix.getlength(0); row++) for (int col=0; col<matrix.getlength(1); col++) Console.Write("0 ", matrix[row, col]); Console.WriteLine(); Can have standard C-style jagged arrays int[] array = new int[30]; int[][] array = new int[2][]; array[0] = new int[100]; array[1] = new int[1]; Stored in random parts of the heap Stored in row major order Dynamic Arrays List<T> Lists are arrays that resize dynamically When adding or removing elements Also have indexers ( like Array) T is the type that the List will hold E.g. List<int> will hold integers List<object> will hold objects Basic Methods and Properties Add(T element) adds new element to the end Remove(element) removes the element Count returns the current size of the List List<int> intlist=new List<int>(); for( int i=0; i<5; i++) intlist.add(i); Is the same as The main difference int[] intarray=new int[5]; for( int i=0; i<5; i++) intarray[i] = i; When using lists we don't have to know the exact number of elements EEE-425 Programming Languages (2013) 12
13 List<string> days = new List<string>(); //Add to the list days.add("monday"); days.add("tuesday"); days.add("saturday"); //reverse the list days.reverse(); //to learn how many elements it has Console.WriteLine("The number of Elements:0", days.count); //Remove from the List days.remove("tuesday"); foreach (string eleman in days) Console.WriteLine(eleman); Lets have an array with capacity of 5 elements int[] intarray=new int[5]; If we want to add a sixth element ( we have already added 5) we have to do int[] intarray = new int[5]; int newvalue = 99; int[] copyarray = intarray; intarray = new int[6]; for (int i = 0; i < 5; i++) copyarray[i] = i; for (int i = 0; i < 5; i++) intarray[i] = copyarray[i]; intarray[5] = newvalue; for (int i = 0; i < 6; i++) Console.WriteLine(intArray[i]); With List we simply do list.add(newvalue); int newvalue = 99; List<int> intlist = new List<int>(); for (int i = 0; i < 5; i++) intlist.add(i); intlist.add(newvalue); for (int i=0; i<6; i++) Console.WriteLine(intList[i]); Sometimes we must copy the values from one array to another one If we do it the intuitive way // Copy the source to the target. // Array.Copy(source, target, n); n size of the array Questions? 75 Prof. Roger Crawfis Pls listen the podcast about the chapter 2 These slides are changed and modified Programming C#, 4th Edition - Jesse Liberty Chapter 2 77 EEE-425 Programming Languages (2013) 13
Visual C# Instructor s Manual Table of Contents
Visual C# 2005 2-1 Chapter 2 Using Data At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion Topics Additional Projects Additional Resources Key Terms
More informationIntroduction to C# Applications
1 2 3 Introduction to C# Applications OBJECTIVES To write simple C# applications To write statements that input and output data to the screen. To declare and use data of various types. To write decision-making
More informationChapter 2: Using Data
Chapter 2: Using Data Declaring Variables Constant Cannot be changed after a program is compiled Variable A named location in computer memory that can hold different values at different points in time
More informationDigiPen Institute of Technology
DigiPen Institute of Technology Presents Session Two: Overview of C# Programming DigiPen Institute of Technology 5001 150th Ave NE, Redmond, WA 98052 Phone: (425) 558-0299 www.digipen.edu 2005 DigiPen
More informationIntroduce C# as Object Oriented programming language. Explain, tokens,
Module 2 98 Assignment 1 Introduce C# as Object Oriented programming language. Explain, tokens, lexicals and control flow constructs. 99 The C# Family Tree C Platform Independence C++ Object Orientation
More informationObjectives. Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments
Basics Objectives Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments 2 Class Keyword class used to define new type specify
More information.Net Technologies. Components of.net Framework
.Net Technologies Components of.net Framework There are many articles are available in the web on this topic; I just want to add one more article over the web by explaining Components of.net Framework.
More informationDuhok Polytechnic University Amedi Technical Institute/ IT Dept. Halkawt Rajab Hussain
Duhok Polytechnic University Amedi Technical Institute/ IT Dept. By Halkawt Rajab Hussain 2016-04-02 Overview. C# program structure. Variables and Constant. Conditional statement (if, if/else, nested if
More informationIntroduction To C#.NET
Introduction To C#.NET Microsoft.Net was formerly known as Next Generation Windows Services(NGWS).It is a completely new platform for developing the next generation of windows/web applications. However
More informationHierarchical inheritance: Contains one base class and multiple derived classes of the same base class.
1. What is C#? C# (pronounced "C sharp") is a simple, modern, object oriented, and type safe programming language. It will immediately be familiar to C and C++ programmers. C# combines the high productivity
More informationC# Fundamentals. Hans-Wolfgang Loidl School of Mathematical and Computer Sciences, Heriot-Watt University, Edinburgh
C# Fundamentals Hans-Wolfgang Loidl School of Mathematical and Computer Sciences, Heriot-Watt University, Edinburgh Semester 1 2018/19 H-W. Loidl (Heriot-Watt Univ) F20SC/F21SC 2018/19
More informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More informationWeiss Chapter 1 terminology (parenthesized numbers are page numbers)
Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement
More informationChapter 1 Getting Started
Chapter 1 Getting Started The C# class Just like all object oriented programming languages, C# supports the concept of a class. A class is a little like a data structure in that it aggregates different
More informationC# Types. Industrial Programming. Value Types. Signed and Unsigned. Lecture 3: C# Fundamentals
C# Types Industrial Programming Lecture 3: C# Fundamentals Industrial Programming 1 Industrial Programming 2 Value Types Memory location contains the data. Integers: Signed: sbyte, int, short, long Unsigned:
More informationLanguage Specification
# Language Specification File: C# Language Specification.doc Last saved: 5/7/2001 Version 0.28 Copyright? Microsoft Corporation 1999-2000. All Rights Reserved. Please send corrections, comments, and other
More informationIndustrial Programming
Industrial Programming Lecture 3: C# Fundamentals Industrial Programming 1 C# Types Industrial Programming 2 Value Types Memory location contains the data. Integers: Signed: sbyte, int, short, long Unsigned:
More information1 Lexical Considerations
Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2013 Handout Decaf Language Thursday, Feb 7 The project for the course is to write a compiler
More informationTable of Contents Preface Bare Necessities... 17
Table of Contents Preface... 13 What this book is about?... 13 Who is this book for?... 14 What to read next?... 14 Personages... 14 Style conventions... 15 More information... 15 Bare Necessities... 17
More informationLexical Considerations
Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2010 Handout Decaf Language Tuesday, Feb 2 The project for the course is to write a compiler
More informationFull file at
Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class
More informationC # Language Specification
C # Language Specification Copyright Microsoft Corporation 1999-2001. All Rights Reserved. Please send corrections, comments, and other feedback to sharp@microsoft.com Notice 1999-2001 Microsoft Corporation.
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 informationC# Language Specification
Standard ECMA- December 00 Standardizing Information and Communication Systems C# Language Specification. Phone: +.0.00 - Fax: +.0.0 - URL: http://www.ecma.ch - Internet: helpdesk@ecma.ch Brief history
More informationLexical Considerations
Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Fall 2005 Handout 6 Decaf Language Wednesday, September 7 The project for the course is to write a
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 informationObjectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program
Objectives Chapter 2: Basic Elements of C++ In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates
More informationChapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction
Chapter 2: Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 1 Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers
More informationJava Language Basics: Introduction To Java, Basic Features, Java Virtual Machine Concepts, Primitive Data Type And Variables, Java Operators,
Java Language Basics: Introduction To Java, Basic Features, Java Virtual Machine Concepts, Primitive Data Type And Variables, Java Operators, Expressions, Statements and Arrays. Java technology is: A programming
More informationCS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University
CS 112 Introduction to Computing II Wayne Snyder Department Boston University Today: Java basics: Compilation vs Interpretation Program structure Statements Values Variables Types Operators and Expressions
More informationThis tutorial has been prepared for the beginners to help them understand basics of c# Programming.
About thetutorial C# is a simple, modern, general-purpose, object-oriented programming language developed by Microsoft within its.net initiative led by Anders Hejlsberg. This tutorial covers basic C# programming
More informationegrapher Language Reference Manual
egrapher Language Reference Manual Long Long: ll3078@columbia.edu Xinli Jia: xj2191@columbia.edu Jiefu Ying: jy2799@columbia.edu Linnan Wang: lw2645@columbia.edu Darren Chen: dsc2155@columbia.edu 1. Introduction
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 information3. Java - Language Constructs I
Educational Objectives 3. Java - Language Constructs I Names and Identifiers, Variables, Assignments, Constants, Datatypes, Operations, Evaluation of Expressions, Type Conversions You know the basic blocks
More informationDAD Lab. 1 Introduc7on to C#
DAD 2017-18 Lab. 1 Introduc7on to C# Summary 1..NET Framework Architecture 2. C# Language Syntax C# vs. Java vs C++ 3. IDE: MS Visual Studio Tools Console and WinForm Applica7ons 1..NET Framework Introduc7on
More informationLesson 02 Working with Data Types. MIT 31043: VISUAL PROGRAMMING By: S. Sabraz Nawaz Senior Lecturer in MIT
Lesson 02 Working with Data Types MIT 31043: VISUAL PROGRAMMING Senior Lecturer in MIT Variables A variable is a storage location in memory that is represented by a name. A variable stores data, which
More informationThe Warhol Language Reference Manual
The Warhol Language Reference Manual Martina Atabong maa2247 Charvinia Neblett cdn2118 Samuel Nnodim son2105 Catherine Wes ciw2109 Sarina Xie sx2166 Introduction Warhol is a functional and imperative programming
More informationChapter 6. Simple C# Programs
6 Simple C# Programs Chapter 6 Voigtlander Bessa-L / 15mm Super Wide-Heliar Chipotle Rosslyn, VA Simple C# Programs Learning Objectives State the required parts of a simple console application State the
More informationChapter 2: Using Data
Chapter 2: Using Data TRUE/FALSE 1. A variable can hold more than one value at a time. F PTS: 1 REF: 52 2. The legal integer values are -2 31 through 2 31-1. These are the highest and lowest values that
More informationJava+- Language Reference Manual
Fall 2016 COMS4115 Programming Languages & Translators Java+- Language Reference Manual Authors Ashley Daguanno (ad3079) - Manager Anna Wen (aw2802) - Tester Tin Nilar Hlaing (th2520) - Systems Architect
More informationControl Flow. COMS W1007 Introduction to Computer Science. Christopher Conway 3 June 2003
Control Flow COMS W1007 Introduction to Computer Science Christopher Conway 3 June 2003 Overflow from Last Time: Why Types? Assembly code is typeless. You can take any 32 bits in memory, say this is an
More informationChapter 2: Basic Elements of C++
Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates
More informationDecaf Language Reference Manual
Decaf Language Reference Manual C. R. Ramakrishnan Department of Computer Science SUNY at Stony Brook Stony Brook, NY 11794-4400 cram@cs.stonybrook.edu February 12, 2012 Decaf is a small object oriented
More informationCourse Outline. Introduction to java
Course Outline 1. Introduction to OO programming 2. Language Basics Syntax and Semantics 3. Algorithms, stepwise refinements. 4. Quiz/Assignment ( 5. Repetitions (for loops) 6. Writing simple classes 7.
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 informationC#.Net. Course Contents. Course contents VT BizTalk. No exam, but laborations
, 1 C#.Net VT 2009 Course Contents C# 6 hp approx. BizTalk 1,5 hp approx. No exam, but laborations Course contents Architecture Visual Studio Syntax Classes Forms Class Libraries Inheritance Other C# essentials
More informationC++ Basics. Data Processing Course, I. Hrivnacova, IPN Orsay
C++ Basics Data Processing Course, I. Hrivnacova, IPN Orsay The First Program Comments Function main() Input and Output Namespaces Variables Fundamental Types Operators Control constructs 1 C++ Programming
More informationFall Semester (081) Dr. El-Sayed El-Alfy Computer Science Department King Fahd University of Petroleum and Minerals
INTERNET PROTOCOLS AND CLIENT-SERVER PROGRAMMING Client SWE344 request Internet response Fall Semester 2008-2009 (081) Server Module 2.1: C# Programming Essentials (Part 1) Dr. El-Sayed El-Alfy Computer
More informationGetting started 7. Storing values 21. Creating variables 22 Reading input 24 Employing arrays 26 Casting data types 28 Fixing constants 30 Summary 32
Contents 1 2 3 Contents Getting started 7 Introducing C# 8 Installing Visual Studio 10 Exploring the IDE 12 Starting a Console project 14 Writing your first program 16 Following the rules 18 Summary 20
More informationIT 374 C# and Applications/ IT695 C# Data Structures
IT 374 C# and Applications/ IT695 C# Data Structures Module 2.1: Introduction to C# App Programming Xianrong (Shawn) Zheng Spring 2017 1 Outline Introduction Creating a Simple App String Interpolation
More informationAbsolute C++ Walter Savitch
Absolute C++ sixth edition Walter Savitch Global edition This page intentionally left blank Absolute C++, Global Edition Cover Title Page Copyright Page Preface Acknowledgments Brief Contents Contents
More informationLesson 02 Working with Data Types MIT 31043, Visual Programming By: S. Sabraz Nawaz
Lesson 02 Working with Data Types MIT 31043, Visual Programming By: S. Sabraz Nawaz Senior Lecturer in MIT Department of MIT Faculty of Management and Commerce South Eastern University of Sri Lanka Variables
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 information6.096 Introduction to C++ January (IAP) 2009
MIT OpenCourseWare http://ocw.mit.edu 6.096 Introduction to C++ January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. Welcome to 6.096 Lecture
More informationC++ Programming: From Problem Analysis to Program Design, Third Edition
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 2: Basic Elements of C++ Objectives (continued) Become familiar with the use of increment and decrement operators Examine
More informationFeatures of C. Portable Procedural / Modular Structured Language Statically typed Middle level language
1 History C is a general-purpose, high-level language that was originally developed by Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. C was originally first implemented on the DEC
More informationJava Overview An introduction to the Java Programming Language
Java Overview An introduction to the Java Programming Language Produced by: Eamonn de Leastar (edeleastar@wit.ie) Dr. Siobhan Drohan (sdrohan@wit.ie) Department of Computing and Mathematics http://www.wit.ie/
More informationC++ Basic Elements of COMPUTER PROGRAMMING. Special symbols include: Word symbols. Objectives. Programming. Symbols. Symbols.
EEE-117 COMPUTER PROGRAMMING Basic Elements of C++ Objectives General Questions Become familiar with the basic components of a C++ program functions, special symbols, and identifiers Data types Arithmetic
More informationBrief Summary of Java
Brief Summary of Java Java programs are compiled into an intermediate format, known as bytecode, and then run through an interpreter that executes in a Java Virtual Machine (JVM). The basic syntax of Java
More informationCS1622. Semantic Analysis. The Compiler So Far. Lecture 15 Semantic Analysis. How to build symbol tables How to use them to find
CS1622 Lecture 15 Semantic Analysis CS 1622 Lecture 15 1 Semantic Analysis How to build symbol tables How to use them to find multiply-declared and undeclared variables. How to perform type checking CS
More informationCS201 - Introduction to Programming Glossary By
CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with
More informationCS260 Intro to Java & Android 03.Java Language Basics
03.Java Language Basics http://www.tutorialspoint.com/java/index.htm CS260 - Intro to Java & Android 1 What is the distinction between fields and variables? Java has the following kinds of variables: Instance
More information3. Except for strings, double quotes, identifiers, and keywords, C++ ignores all white space.
Chapter 2: Problem Solving Using C++ TRUE/FALSE 1. Modular programs are easier to develop, correct, and modify than programs constructed in some other manner. ANS: T PTS: 1 REF: 45 2. One important requirement
More informationIPCoreL. Phillip Duane Douglas, Jr. 11/3/2010
IPCoreL Programming Language Reference Manual Phillip Duane Douglas, Jr. 11/3/2010 The IPCoreL Programming Language Reference Manual provides concise information about the grammar, syntax, semantics, and
More informationCSCI 1061U Programming Workshop 2. C++ Basics
CSCI 1061U Programming Workshop 2 C++ Basics 1 Learning Objectives Introduction to C++ Origins, Object-Oriented Programming, Terms Variables, Expressions, and Assignment Statements Console Input/Output
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 informationArray. Prepared By - Rifat Shahriyar
Java More Details Array 2 Arrays A group of variables containing values that all have the same type Arrays are fixed length entities In Java, arrays are objects, so they are considered reference types
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 informationTools : The Java Compiler. The Java Interpreter. The Java Debugger
Tools : The Java Compiler javac [ options ] filename.java... -depend: Causes recompilation of class files on which the source files given as command line arguments recursively depend. -O: Optimizes code,
More informationOperators and Expressions
Operators and Expressions Conversions. Widening and Narrowing Primitive Conversions Widening and Narrowing Reference Conversions Conversions up the type hierarchy are called widening reference conversions
More informationC#: framework overview and in-the-small features
Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer C#: framework overview and in-the-small features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer
More informationCOMP 202 Java in one week
COMP 202 Java in one week... Continued CONTENTS: Return to material from previous lecture At-home programming exercises Please Do Ask Questions It's perfectly normal not to understand everything Most of
More informationObjectives. In this chapter, you will:
Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates arithmetic expressions Learn about
More informationChapter 2 Basic Elements of C++
C++ Programming: From Problem Analysis to Program Design, Fifth Edition 2-1 Chapter 2 Basic Elements of C++ At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class Discussion
More informationA Comparison of Visual Basic.NET and C#
Appendix B A Comparison of Visual Basic.NET and C# A NUMBER OF LANGUAGES work with the.net Framework. Microsoft is releasing the following four languages with its Visual Studio.NET product: C#, Visual
More informationShort Notes of CS201
#includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system
More informationJava Primer 1: Types, Classes and Operators
Java Primer 1 3/18/14 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser, Wiley, 2014 Java Primer 1: Types,
More informationComputer Programming : C++
The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2003 Muath i.alnabris Computer Programming : C++ Experiment #1 Basics Contents Structure of a program
More informationProblem Solving with C++
GLOBAL EDITION Problem Solving with C++ NINTH EDITION Walter Savitch Kendrick Mock Ninth Edition PROBLEM SOLVING with C++ Problem Solving with C++, Global Edition Cover Title Copyright Contents Chapter
More information3. Java - Language Constructs I
Names and Identifiers A program (that is, a class) needs a name public class SudokuSolver {... 3. Java - Language Constructs I Names and Identifiers, Variables, Assignments, Constants, Datatypes, Operations,
More informationLearning C# 3.0. Jesse Liberty and Brian MacDonald O'REILLY. Beijing Cambridge Farnham Köln Sebastopol Taipei Tokyo
Learning C# 3.0 Jesse Liberty and Brian MacDonald O'REILLY Beijing Cambridge Farnham Köln Sebastopol Taipei Tokyo Table of Contents Preface xv 1. C# and.net Programming 1 Installing C# Express 2 C# 3.0
More informationIntroduction to C# Applications Pearson Education, Inc. All rights reserved.
1 3 Introduction to C# Applications 2 What s in a name? That which we call a rose by any other name would smell as sweet. William Shakespeare When faced with a decision, I always ask, What would be the
More informationTokens, Expressions and Control Structures
3 Tokens, Expressions and Control Structures Tokens Keywords Identifiers Data types User-defined types Derived types Symbolic constants Declaration of variables Initialization Reference variables Type
More information1. Describe History of C++? 2. What is Dev. C++? 3. Why Use Dev. C++ instead of C++ DOS IDE?
1. Describe History of C++? The C++ programming language has a history going back to 1979, when Bjarne Stroustrup was doing work for his Ph.D. thesis. One of the languages Stroustrup had the opportunity
More informationClient-Side Web Technologies. JavaScript Part I
Client-Side Web Technologies JavaScript Part I JavaScript First appeared in 1996 in Netscape Navigator Main purpose was to handle input validation that was currently being done server-side Now a powerful
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 informationWelcome Back. CSCI 262 Data Structures. Hello, Let s Review. Hello, Let s Review. How to Review 8/19/ Review. Here s a simple C++ program:
Welcome Back CSCI 262 Data Structures 2 - Review What you learned in CSCI 261 (or equivalent): Variables Types Arrays Expressions Conditionals Branches & Loops Functions Recursion Classes & Objects Streams
More informationCS201- Introduction to Programming Latest Solved Mcqs from Midterm Papers May 07,2011. MIDTERM EXAMINATION Spring 2010
CS201- Introduction to Programming Latest Solved Mcqs from Midterm Papers May 07,2011 Lectures 1-22 Moaaz Siddiq Asad Ali Latest Mcqs MIDTERM EXAMINATION Spring 2010 Question No: 1 ( Marks: 1 ) - Please
More informationPreview from Notesale.co.uk Page 6 of 52
Binary System: The information, which it is stored or manipulated by the computer memory it will be done in binary mode. RAM: This is also called as real memory, physical memory or simply memory. In order
More informationCS201 Some Important Definitions
CS201 Some Important Definitions For Viva Preparation 1. What is a program? A program is a precise sequence of steps to solve a particular problem. 2. What is a class? We write a C++ program using data
More information4 Programming Fundamentals. Introduction to Programming 1 1
4 Programming Fundamentals Introduction to Programming 1 1 Objectives At the end of the lesson, the student should be able to: Identify the basic parts of a Java program Differentiate among Java literals,
More informationAppendix. Grammar. A.1 Introduction. A.2 Keywords. There is no worse danger for a teacher than to teach words instead of things.
A Appendix Grammar There is no worse danger for a teacher than to teach words instead of things. Marc Block Introduction keywords lexical conventions programs expressions statements declarations declarators
More informationPace University. Fundamental Concepts of CS121 1
Pace University Fundamental Concepts of CS121 1 Dr. Lixin Tao http://csis.pace.edu/~lixin Computer Science Department Pace University October 12, 2005 This document complements my tutorial Introduction
More informationEMBEDDED SYSTEMS PROGRAMMING Language Basics
EMBEDDED SYSTEMS PROGRAMMING 2015-16 Language Basics "The tower of Babel" by Pieter Bruegel the Elder Kunsthistorisches Museum, Vienna (PROGRAMMING) LANGUAGES ABOUT THE LANGUAGES C (1972) Designed to replace
More informationZhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson
Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson Introduction History, Characteristics of Java language Java Language Basics Data types, Variables, Operators and Expressions Anatomy of a Java Program
More informationNOIDATUT E Leaning Platform
NOIDATUT E Leaning Platform Dot Net Framework Lab Manual COMPUTER SCIENCE AND ENGINEERING Presented by: NOIDATUT Email : e-learn@noidatut.com www.noidatut.com C SHARP 1. Program to display Hello World
More informationG Programming Languages - Fall 2012
G22.2110-003 Programming Languages - Fall 2012 Lecture 3 Thomas Wies New York University Review Last week Names and Bindings Lifetimes and Allocation Garbage Collection Scope Outline Control Flow Sequencing
More informationCISC-124. Dog.java looks like this. I have added some explanatory comments in the code, and more explanation after the code listing.
CISC-124 20180115 20180116 20180118 We continued our introductory exploration of Java and object-oriented programming by looking at a program that uses two classes. We created a Java file Dog.java and
More informationExpressions and Data Types CSC 121 Fall 2015 Howard Rosenthal
Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types and
More informationMicrosoft Visual C# Step by Step. John Sharp
Microsoft Visual C# 2013 Step by Step John Sharp Introduction xix PART I INTRODUCING MICROSOFT VISUAL C# AND MICROSOFT VISUAL STUDIO 2013 Chapter 1 Welcome to C# 3 Beginning programming with the Visual
More information