Module 2 Variables, Assignment, and Data Types

Slides:



Advertisements
Similar presentations
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics C# Language &.NET Platform 6 th Lecture Pavel Ježek
Advertisements

C# Language Report By Trevor Adams. Language History Developed by Microsoft Developed by Microsoft Principal Software Architect Principal Software Architect.
C++ Basics Variables, Identifiers, Assignments, Input/Output.
Neal Stublen C# Data Types Built-in Types  Integer Types byte, sbyte, short, ushort, int, uint, long, ulong  Floating Point Types.
Getting Started with C# 1 SWE 344 Internet Protocols & Client Server Programming.
JAVA PROGRAMMING PART II.
CS 192 Lecture 3 Winter 2003 December 5, 2003 Dr. Shafay Shamail.
COMPUTER PROGRAMMING. Data Types “Hello world” program Does it do a useful work? Writing several lines of code. Compiling the program. Executing the program.
Outline Character Strings Variables and Assignment Primitive Data Types Expressions Data Conversion Interactive Programs Graphics Applets Drawing Shapes.
1 Identifiers  Identifiers are the words a programmer uses in a program  An identifier can be made up of letters, digits, the underscore character (
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
System development with Java Lecture 2. Rina Errors A program can have three types of errors: Syntax and semantic errors – called.
C-Language Keywords(C99)
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
Program Statements Primitive Data Types and Strings.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-WesleyCopyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
Chapter 2: Java Fundamentals
CSC 1051 – Algorithms and Data Structures I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
SE-1010 Dr. Mark L. Hornick 1 Variables & Datatypes.
Assignment An assignment statement changes the value of a variable The assignment operator is the = sign total = 55; Copyright © 2012 Pearson Education,
Computing with C# and the.NET Framework Chapter 2 C# Programming Basics ©2003, 2011 Art Gittleman.
Variables and Data Types.  Variable: Portion of memory for storing a determined value.  Could be numerical, could be character or sequence of characters.
CSCI 3328 Object Oriented Programming in C# Chapter 4: C# Control Statement – Part I 1 Xiang Lian The University of Texas Rio Grande Valley Edinburg, TX.
C# C1 CSC 298 Elements of C# code (part 1). C# C2 Style for identifiers  Identifier: class, method, property (defined shortly) or variable names  class,
Chapter 2 Data and Expressions Part One. © 2004 Pearson Addison-Wesley. All rights reserved2-2/29 Data and Expressions Let's explore some other fundamental.
Bill Campbell, UMB Microsoft's.NET C# and The Common Language Runtime.
Chapter 2 topics Concept # on Java Subset Required for AP Exam print and println10. Testing of output is restricted to System.out.print and System.out.println.
Chapter 2 Data and Expressions Java Software Solutions Foundations of Program Design 1.
C# - variablesBjørk Busch1 Variables Basic types (also defined as classes with methods) : Integer-types Int, long, byte, sbyte, short, ushort, uint, ulong.
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics C# Language &.NET Platform 8 th Lecture Pavel Ježek
1 CSC 1111 Introduction to Computing using C++ C++ Basics (Part 1)
1 Lecture # 2. * Introducing Programming with an Example * Identifiers, Variables, and Constants * Primitive Data Types * Byte, short, int, long, float,
Introduction C# program is collection of classes Classes are collection of methods and some statements That statements contains tokens C# includes five.
C++ Lesson 1.
Asst.Prof.Dr. Tayfun ÖZGÜR
Variables, Identifiers, Assignments, Input/Output
Basic Introduction to C#
Intermediate Java Programming
C# — Console Application
Data types Data types Basic types
Lecture 2: Data Types, Variables, Operators, and Expressions
University of Central Florida COP 3330 Object Oriented Programming
Computing with C# and the .NET Framework
Chapter 2 Data and Expressions
Reserved Words.
Chapter 2.
Escape Sequences What if we wanted to print the quote character?
Data and Expressions Part One
CSCI 3328 Object Oriented Programming in C# Chapter 4: C# Control Statement – Part I UTPA – Fall 2012 This set of slides is revised from lecture slides.
null, true, and false are also reserved.
C++ Basics.
Introduction to Java Programming
Variables, Loops, Decision Statements, etc
Basics of ‘C’.
An overview of Java, Data types and variables
ניתוח מערכות מידע תכנות ב C#
Variables, Identifiers, Assignments, Input/Output
Units with – James tedder
Chapter 2 Create a Chapter 2 Workspace Create a Project called Notes
JavaScript Reserved Words
The important features of OOP related to C#:
Module 2 - Part 1 Variables, Assignment, and Data Types
Module 2 - Part 1 Variables, Assignment, and Data Types
Programming Language C Language.
Agenda Types and identifiers Practice Assignment Keywords in Java
CSC 1051 – Data Structures and Algorithms I
Module 2 - Part 1 Variables, Assignment, and Data Types
Java Programming Presented by Dr. K. SATISH KUMAR,
Module 2 - Part 1 Variables, Assignment, and Data Types
Presentation transcript:

Module 2 Variables, Assignment, and Data Types 4/4/2019 CSE 1321 Module 2

C# Keywords (bad for variable names) abstract as base bool break byte case catch char checked class const continue decimal default delegate do double else enum event explicit extern false finally fixed float for foreach goto if implicit in int interface internal is lock long namespace new null object operator out override params private protected public readonly ref return sbyte sealed short sizeof stackalloc static string struct switch this throw true try typeof uint ulong unchecked unsafe ushort using var virtual void volatile while 4/4/2019 CSE 1321 Module 2

Printing strings in C# (review) Console.WriteLine (“Whatever you are, be a good one.”); Console represents the Operating System’s console WriteLine is a “function” to push data to the console 4/4/2019 CSE 1321 Module 2 3

Pseudocode CLASS CountDown BEGIN METHOD Main() BEGIN s1 ← "Three... " s2 ← "Two... " s3 ← "One... " s4 ← "Zero... " PRINT(s1 + s2 + s3 + s4 + "Liftoff!") PRINTLINE() PRINT("Houston, we have a problem.") END Main END CountDown Output: Three... Two... One... Zero... Liftoff! Houston, we have a problem. Ps 4/4/2019 CSE 1321 Module 2 4

C# Output: using System; class CountDown { public static void Main(string[] args) { Console.Write("Three... "); Console.Write("Two... "); Console.Write("One... "); Console.Write("Zero... "); Console.WriteLine("Liftoff!"); //on first line Console.WriteLine("Houston, we have a problem. "); } Output: Three... Two... One... Zero... Liftoff! Houston, we have a problem. 4/4/2019 CSE 1321 Module 2 5

Escape Sequences Printing and escape sequence prints a special character in an output string. Common escape sequences: \b backspace. (e.g “B\bsecz\bret” prints what?) \t tab \n newline \r carriage return \” double quote \’ single quote \\ backslash 4/4/2019 CSE 1321 Module 2 6

C# // Escape sequences class Roses { public static void Main(string [] args) Console.WriteLine("Roses are red,\n\tViolets are blue,\n" + "Sugar is sweet,\n\tBut I have " + "\"commitment issues\",\n\t" + "So I'd rather just be friends\n\t" + "At this point in our relationship."); } 4/4/2019 CSE 1321 Module 2 7

Ps Pseudocode // Prints the number of keys on a piano. CLASS PianoKeys BEGIN METHOD Main() BEGIN keys ← 88 PRINT("A piano has " + keys + " keys.") END Main END PianoKeys Output: A piano has 88 keys. Ps 4/4/2019 CSE 1321 Module 2 8

C# // Prints the number of keys on a piano using System; class PianoKeys { public static void Main (string[] args) { int keys = 88; //declare and initialize Console.WriteLine("A piano has " + keys + " keys."); } Output: A piano has 88 keys. 4/4/2019 CSE 1321 Module 2 9

Pseudocode // Print the number of sides of several geometric shapes. CLASS Geometry BEGIN METHOD Main() sides ← 7 PRINT("A heptagon has " + sides + " sides.") sides ← 10 PRINT("A decagon has " + sides + " sides.") sides ← 12 PRINT("A dodecagon has " + sides + " sides.") END Main END Geometry Output: A heptagon has 7 sides. A decagon has 10 sides. A dodecagon has 12 sides. Ps 4/4/2019 CSE 1321 Module 2 10

C# // Print the number of sides of several geometric shapes. using System; class Geometry { public static void Main (string[] args) { int sides = 7; // declare and initialize Console.WriteLine("A heptagon has " + sides + " sides."); sides = 10; // assignment statement Console.WriteLine("A decagon has " + sides + " sides."); sides = 12; // assignment statement Console.WriteLine("A dodecagon has " + sides + " sides."); } 4/4/2019 CSE 1321 Module 2 11