Variables, Loops, Decision Statements, etc

Slides:



Advertisements
Similar presentations
Control Structures.
Advertisements

AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
2. C# Language Fundamentals
Procedural Programming in C# Chapters Objectives You will be able to: Describe the most important data types available in C#. Read numeric values.
STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
Making Choices in C if/else statement logical operators break and continue statements switch statement the conditional operator.
C# Language Report By Trevor Adams. Language History Developed by Microsoft Developed by Microsoft Principal Software Architect Principal Software Architect.
C++ Basics March 10th. A C++ program //if necessary include headers //#include void main() { //variable declaration //read values input from user //computation.
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.
פתרון בוחן הכיתה. שאלה #1 Module Module1 Sub Main() Dim x, z As Integer x = Console.ReadLine() z = Console.ReadLine() If (x = 0) Then Console.WriteLine("Error")
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.
Introduction to Classes and Objects (Through Ch 5) Dr. John P. Abraham Professor UTPA.
1. 2 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Decisions { class.
 For Loops › for (variable set; condition; incremental or decrement){ // loop beginning › } // loop end  While loops › while (condition) { // beginning.
3. Declaring Value-Type Variables
CSCI 3328 Object Oriented Programming in C# Chapter 3: Introduction to Classes and Objects UTPA – Fall
Basic Java Programming CSCI 392 Week Two. Stuff that is the same as C++ for loops and while loops for (int i=0; i
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.
CSCI 3328 Object Oriented Programming in C# Chapter 5: C# Control Statement – Part II UTPA – Fall
Chapter 2: Using Data.
STATEMENTS AND FLOW OF EXECUTION CHAPTER 11 OF APRESS A PROGRAMMERS GUIDE TO C SHARP 5.0.
Chapter 3:Decision Structures.  3.1 The if Statement  3.2 The if-else Statement  3.3 The if-else-if Statement  3.4 Nested if Statements  3.5 Logical.
Chapter 05 (Part III) Control Statements: Part II.
Computing with C# and the.NET Framework Chapter 2 C# Programming Basics ©2003, 2011 Art Gittleman.
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,
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
1.2 Primitive Data Types and Variables
Chapter One Lesson Three DATA TYPES ©
Computing with C# and the.NET Framework Chapter 4 More Control Structures and Types ©2003, 2011 Art Gittleman.
2: Basics Basics Programming C# © 2003 DevelopMentor, Inc. 12/1/2003.
Test Review. General Info. All tests will be comprehensive. You will be tested more on your understanding of code as opposed to your ability to write.
 2002 Prentice Hall. All rights reserved. 1 Chapter 4 – Control Structures Part 1 Outline Counter-Controlled Repetition: Example Sentinel-Controlled Repetition:
A Introduction to Computing II Lecture 1: Java Review Fall Session 2000.
Computer Programs CS 1400 Dennis A. Fairclough Version 1.1 CS 1400 Dennis A. Fairclough Version 1.1.
A DVANCED P ROGRAMMING C HAPTER 5 & 6: C ONTROL S TRUCTURES Dr Shahriar Bijani Spring 2016.
Lecture 2 Review of 1301 and C# Richard Gesick. Common data types int, long, double, float, char, bool, string.
C syntax (simplified) BNF. Program ::= [ ] Directives ::= [ ] ::= | |… ::=#include > ::=#define.
1 ENERGY 211 / CME 211 Lecture 3 September 26, 2008.
C++ Lesson 1.
Basic Introduction to C#
CIS3931 – Intro to JAVA Lecture Note Set 2 17-May-05.
C# and the .NET Framework
C# — Console Application
C++, OBJECT ORIENTED PROGRAMMING
Computing with C# and the .NET Framework
CS 1430: Programming in C++.
Chapter 2.
Dr Shahriar Bijani Winter 2017
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.
.Net Programming with C#
Introduction to Programming
Advanced Programming Chapters 5 & 6: Control Structures
An Introduction to Java – Part I, language basics
C# Control Statements part 1 (Based on Deitel Book)
ניתוח מערכות מידע תכנות ב C#
CSCI 3328 Object Oriented Programming in C# Chapter 3: Introduction to Classes and Objects UTPA – Fall 2012 This set of slides is revised from lecture.
Data Types Imran Rashid CTO at ManiWeber Technologies.
The important features of OOP related to C#:
Lecture 1 Review of 1301/1321 CSE /26/2018.
Module 2 Variables, Assignment, and Data Types
Visual Programming COMP-315
Lecture 14 2D Arrays Richard Gesick.
Fundamental Programming
Welcome back to Software Development!
The switch Statement When we want to compare a variable against several values to see which one it has, we can use the switch statement: switch (status)
Arrays and Strings CSCI293 - C# September 26, 2005.
Agenda Types and identifiers Practice Assignment Keywords in Java
Presentation transcript:

Variables, Loops, Decision Statements, etc C# Basics Variables, Loops, Decision Statements, etc

Variables Declarations byte - 0 to 255 char - 2 bytes bool sbyte - -128 to 127 short - 2 byte int ushort - 0 to 65,535 int - 4 bytes uint - 4 bytes positive float double decimal long ulong string

Using Variables C# is Strongly Typed float x = 10.9f; double y = 15.3; y = x; // okay x = (float) y; // conversion required Variables must have Value before being used. Hence declarations usually include initialization

Simple Arrays int[] myArray1 = new int[5]; for (int i=0;i<10; i++) Console.Write ("{0} ",myarray[i]); Console.WriteLine();

Looping Statements Same as C++ Different from C++ while (count > 0) process_list (count--); do process_list( ++count ); while (count < 10); for (int i=1; i<=10; i++) Different from C++ while (count)// illegal C# unless count is bool

Decision Statements Almost Just Like C++ if (count >= 10) { dostuff(); domorestuff(); } else ... switch (choice) { case 'Y': //must be empty case 'y': do_yes_stuff(); break; default: ...

Simple Console Output System.Console.WriteLine System.Console.Write System.Consolue.WriteLine ("count = {0} and sum = {1}", count, sum);

Simple Console Input string inputline; char charvalue; int intvalue; Console.Write ("Enter a string: "); inputline = Console.ReadLine(); Console.WriteLine("You just entered \"{0}\"",inputline); Console.Write ("Enter a character: "); charvalue = (char) Console.Read(); Console.WriteLine("You just entered \"{0}\"", charvalue); Console.ReadLine(); Console.Write ("Enter an integer: "); intvalue = Convert.ToInt32(inputline); Console.WriteLine("You just entered \"{0}\"", intvalue);