1 st Semester 2005 1 Module2 Basic C# Concept อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering.

Slides:



Advertisements
Similar presentations
1 Demo Reading Assignments Important terms & concepts Fundamental Data Types Identifier Naming Arithmetic Operations Sample Programs CSE Lecture.
Advertisements

Java Syntax Part I Comments Identifiers Primitive Data Types Assignment.
Announcements Quiz 1 Next Week. int : Integer Range of Typically -32,768 to 32,767 (machine and compiler dependent) float : Real Number (i.e., integer.
An Introduction to Programming with C++ Fifth Edition Chapter 4 Chapter 4: Variables, Constants, and Arithmetic Operators.
Data types and variables
An Introduction to Programming with C++ Fifth Edition Chapter 4 Chapter 4: Variables, Constants, and Arithmetic Operators.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie June 27, 2005.
Admin Office hours 2:45-3:15 today due to department meeting if you change addresses during the semester, please unsubscribe the old one from the.
Basic Elements of C++ Chapter 2.
Introduction to C++ Programming
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
Thanachat Thanomkulabut
1 Chapter Two Using Data. 2 Objectives Learn about variable types and how to declare variables Learn how to display variable values Learn about the integral.
VARIABLES, TYPES, INPUT/OUTPUT, ASSIGNMENT OPERATION Shieu-Hong Lin MATH/CS Department Chapel.
Objectives You should be able to describe: Data Types
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to C++ Programming Outline Introduction to C++ Programming A Simple Program: Printing a.
Introduction to C# Programming ณภัทร สักทอง Application Program Development.
Chapter 2: Basic Elements of Java J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
CH2 – Using Data. Constant Something which cannot be changed Data Type Format and size of a data item Intrinsic Data Types Pg. 47 – Table 2-1 Basic ones.
Chapter 2: Using Data.
Computer Programming TCP1224 Chapter 4 Variables, Constants, and Arithmetic Operators.
UniMAP Sem1-07/08EKT120: Computer Programming1 Week2.
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
C++ Programming: Basic Elements of C++.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 2 Basic Elements of Java.
1 st Semester Module2 Basic C# Concept อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering.
Lecture 2: Introduction to C Programming. OBJECTIVES In this lecture you will learn:  To use simple input and output statements.  The fundamental data.
Programming Fundamental Slides1 Data Types, Identifiers, and Expressions Topics to cover here: Data types Variables and Identifiers Arithmetic and Logical.
1 st Semester Module3 Condition Statement อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering.
C# Basic Concept Thanachat Thanomkulabut. Naming Rules  Letters, digits and underscores(_)  First character  letter or _  Up to 63 characters long.
Computer Engineering 1 st Semester Dr. Rabie A. Ramadan 3.
1 st semester Basic Pascal Elements อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering.
Computing with C# and the.NET Framework Chapter 2 C# Programming Basics ©2003, 2011 Art Gittleman.
Input & Output Statement
VARIABLES AND DATA TYPES Chapter2:part1 1. Objectives: By the end of this section you should: Understand what the variables are and why they are used.
C++ Basics. Compilation What does compilation do? g++ hello.cpp g++ -o hello.cpp hello.
Arithmetic Expressions in C++. CSCE 1062 Outline Data declaration {section 2.3} Arithmetic operators in C++ {section 2.6} Mixed data type arithmetic in.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 2A Reading, Processing and Displaying Data (Concepts)
Variables and Constants Objectives F To understand Identifiers, Variables, and Constants.
1 09/03/04CS150 Introduction to Computer Science 1 What Data Do We Have.
C# Programming: Basic Concept Part 2 Computer and Programming (204111)
Lecture 5 Computer programming -1-. Input \ Output statement 1- Input (cin) : Use to input data from keyboard. Example : cin >> age; 2- Output (cout):
1 nd Semester Module2 C# Basic Concept Thanawin Rakthanmanon Computer Engineering Department Kasetsart University, Bangkok.
Java Programming: From Problem Analysis to Program Design, Second Edition 1 Lecture 1 Objectives  Become familiar with the basic components of a Java.
1 st Semester Module3 Condition Statement อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering.
1 st Semester Module4-1 Iteration statement - while อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer.
UNIMAP Sem2-07/08EKT120: Computer Programming1 Week 2 – Introduction to Programming.
Chapter 4: Variables, Constants, and Arithmetic Operators Introduction to Programming with C++ Fourth Edition.
A Sample Program #include using namespace std; int main(void) { cout
Intro. to Computer Programming Eng. Nehal A. Mohamed Spring Semester-2016.
Chapter 4.  Variables – named memory location that stores a value.  Variables allows the use of meaningful names which makes the code easier to read.
1Object-Oriented Program Development Using C++ Built-in Data Types Data type –Range of values –Set of operations on those values Literal: refers to acceptable.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
1 nd Semester Module6 Review Thanawin Rakthanmanon Create by: Aphirak Jansang Computer Engineering Department Kasetsart.
Bill Tucker Austin Community College COSC 1315
Chapter Topics The Basics of a C++ Program Data Types
BASIC ELEMENTS OF A COMPUTER PROGRAM
Basic Elements of C++.
Data Types, Identifiers, and Expressions
Revision Lecture
Computing with C# and the .NET Framework
Basic Elements of C++ Chapter 2.
Data Types, Identifiers, and Expressions
C# Programming.
Engineering Problem Solving with C++ An Object Based Approach
Engineering Problem Solving with C++ An Object Based Approach
Primitive Types and Expressions
Variables and Constants
Presentation transcript:

1 st Semester Module2 Basic C# Concept อภิรักษ์ จันทร์สร้าง Aphirak Jansang Computer Engineering Department Kasetsart University, Bangkok THAILAND

1 st Semester Outline  C# Overview  Variable and Constant  Expression  Statement

1 st Semester Simple C# program structure Your Class Name Your declaration part Your statements Your Namespace Name C# Overview

1 st Semester Naming Guidelines  Letters, digits, underscores(_)  First character  letter  Can be long (63 char)  Reserved words (keywords) are not allowed *** Case Sensitive *** Example KU65 ≠ kU65 ≠ku65 KU65 ≠ kU65 ≠ ku65 C# Overview

1 st Semester Built-in Namespace: System Console Console class can be used for Displaying Displaying information on the screenSystem.Console.Write(”HelloWorld!”);System.Console.WriteLine(”HelloWorld!”); Retrieving Retrieving information from the user String ch; ch = System.Console.Readline(); C# Overview

1 st Semester How to Comment Code in C# 1 2

1 st Semester Summary C# Program Overview  Namespace Class  Main() C# Overview

1 st Semester Outline  C# Overview  Variable and Constant  Expression  Statement

1 st Semester Basic uses Declaration Part  Variable  Constant Variable & Constant

1 st Semester What is Variable? Variables are used to store “data.” “They must be declared before used” Variable & Constant

1 st Semester C# Declaration Location Declaration Part Here Variable & Constant

1 st Semester C# Variable Declaration  Syntax: ;  Example:  We can also assign its initial value. E.g., int radius; double area; int a,b,c; bool isokay; int k = 200; bool done = false; Variable & Constant

1 st Semester C# Basic Data Type  int Integer ( to )  double Floating-point ( )  bool Boolean values, true and false  char a Unicode character (’A’ ’B’)  string string of Unicode characters (”StarsIII”) Variable & Constant

1 st Semester Example: Variable Declaration Variable & Constant

1 st Semester Basic uses Declaration Part  Variable  Constant Variable & Constant

1 st Semester C# Constant Declaration  Syntax: const = ;  Example: const int radius = 15; const double area=1.5; const bool isokay=true; const string movie=”StarWarIII”; Variable & Constant

1 st Semester Outline  C# Overview  Variable and Constant  Expression  Statement

1 st Semester Arithmetic Expression in C#  Operators + - * / % (remainder after division)  Example  / 2  % 2  % 2.2  0.6Expression

1 st Semester Precedence rules for Arithmetic Operators 1.( ) parentheses 2.*, /, % 3.+ – 4.If equal precedence, left to right Example int Width,High; Width=10*5+(16 * 12)/5; High= (16+5)+20%2;

1 st Semester Outline  C# Overview  Variable and Constant  Expression  Statement

1 st Semester C# Statement LocationStatementsHereStatement

1 st Semester C# Statement Types  Assignment Statement  Input Statement  Output StatementStatement

1 st Semester Assignment Statement "put"  To "put" a value in the memory space allocated to a variable equal sign (=)  Use the equal sign (=) when making assignments.  Syntax: = ; = ; int Width,High; Width=10;High=5; int Width = 10; int High = 5; Statement

1 st Semester Example: Assignment StatementStatement

1 st Semester C# Statement Types  Assignment Statement  Input Statement  Output StatementStatement

1 st Semester Input Statement  Console.ReadLine()  Return string Use to get the input from user  Convert string to other data type int.Parse() Convert string to integer double.Parse() Convert string to double Example string yourname; yourname = Console.ReadLine(); Statement

1 st Semester Example: Input Statement Ex1: string myname; myname = Console.ReadLine(); Ex2: int Width,High; string temp1; temp1 = Console.ReadLine(); Width = int.Parse(temp1); temp1 = Console.ReadLine(); Width = int.Parse(temp1); Statement

1 st Semester C# Statement Types  Assignment Statement  Input Statement  Output StatementStatement

1 st Semester Output Statement  Console.WriteLine(VariableName)  Display variable value in some position of string  Output Formatting Example1 Console.WriteLine(”Hello {0}, {1}”, ps0, ps1); Example2 double salary=12000; Console.WriteLine("My salary is {0:f}.", salary); More information about formatting * Statement

1 st Semester Summary  C# Overview  Variable and Constant  Expression  Statement