• Complain

Ren - Computer Coding

Here you can read online Ren - Computer Coding full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. year: 2021, genre: Computer. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

No cover
  • Book:
    Computer Coding
  • Author:
  • Genre:
  • Year:
    2021
  • Rating:
    5 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 100
    • 1
    • 2
    • 3
    • 4
    • 5

Computer Coding: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Computer Coding" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

Ren: author's other books


Who wrote Computer Coding? Find out the surname, the name of the author of the book and a list of all author's works by series.

Computer Coding — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "Computer Coding" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
Computer
Coding
Zhong Guo Ren Copyright 2020 by Zhong Guo Ren All Rights Reserved Neither part of this book nor whole of this book may be reproduced or transmitted in any form or by any means electronic, photographic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without prior written permission from the author. All rights reserved ! Zhong Guo Ren Preface This book includes various computer programs which are appled to IT industries widely. These programs are designed for the computer coding learners. we can use this book as a referece guide. I T Table of Contents
Program 01
Chapter 1 Example 1.1 using System; namespace HelloWorld { class Program { static void Main(string[] args) { Console.WriteLine("Hello World!"); Console.ReadLine(); } } } Example 1.3 using System; namespace EscapingCharacters{ class Program{ static void Main(string[] args){ Console.WriteLine(" \"Escaping Character Samples\" "); Console.ReadLine(); } } } Example 1.8 using System; namespace VariableSample{ class Program{ static void Main(string[] args){ float x, y; // define x, y y = 1.23456f; x = y; Console.WriteLine(x); int i; // define i int a = 10, b = 20, c = 30; // define a, b, c i = a + b + c; Console.WriteLine(i); Console.ReadLine(); }}} Example 1.10 using System; namespace ConstantSample{ class Program{ static void Main(string[] args){ const double PI = 3.14159265; const string BOOK = "C# Programming Language"; Console.WriteLine(PI); Console.WriteLine(BOOK); Console.ReadLine(); }}} Example 1.11 using System; namespace TypyConvert{ class Program{ static void Main(string[] args){ float oldValue = 20.123f, newValue; newValue = (int)oldValue; // convert data type Console.WriteLine(newValue); Console.ReadLine(); }}} Example 1.12 using System; namespace Boxing{ class Program{ static void Main(string[] args){ int var1 = 100; object var2 = (object)var1; // boxing Console.WriteLine("The data type of var2 is object type now."); Console.ReadLine(); }}} Example 1.13 using System; namespace UnBoxing{ class Program{ static void Main(string[] args){ int var1 = 100; object var2 = (object)var1; // boxing int var3 = (int)var2; // unboxing Console.WriteLine("The data type of var3 is int type now."); Console.ReadLine(); }}} Chapter 2 Example 2.1 int add=100+200; Console.WriteLine (add); int div=800/2; Console.WriteLine ( div ); int mod=10%3; Console.WriteLine ( mod ); int inc=10; Console.WriteLine ( ++inc ); Example 2.2 bool x=true; bool y=false; bool a=x && y; Console.WriteLine ( a ); // output: false bool b=x || y; Console.WriteLine ( b ); // output: true bool c=! x; Console.WriteLine ( c ); // output: false Example 2.3 int x=200; int y=100; x += y; Console.WriteLine ( x ); x /= y; Console.WriteLine ( x ); x -= y; Console.WriteLine ( x ); string m="abc"; string n="de"; m += n; Console.WriteLine(m); Example 2.4 int a = 100; int b = 200; bool result; result = (a > b); Console.WriteLine(result); result = (a == b); Console.WriteLine(result); result = (a != b); Console.WriteLine(result); Example 2.5 using System; namespace CondictionalOperator { class Program { static void Main(string[] args) { int a = 100; int b = 200; string result1 = (a < b) ? "apple" : "banana"; Console.WriteLine("result1 is: " + result1); string result2 = (a > b) ? "apple" : "banana"; Console.WriteLine("result2 is: " + result2); Console.ReadLine(); } } } Example 2.6 int a = 10, num; num = ++a - 2; /* a plus 1equals 11, 11 minus 2 equals 9, then the result "9" assigns to num.*/ Console.WriteLine(num); Example 2.7 int a = 10, num; num = a++ - 2; /* a minus 2 equals 8, the result "8" assigns to num, then a plus 1.*/ Console.WriteLine(num); Example 2.8 using System; namespace sizeofsample{ class Program{ static void Main(string[] args){ Console.WriteLine("The size of short is " + sizeof(short)); Console.WriteLine("The size of int is " + sizeof(int)); Console.WriteLine("The size of long is " + sizeof(long)); Console.ReadLine(); }}} Example 2.9 public struct Car { // defines a struct type public int price; // struct field public string size; // struct field public string color; // struct field } Example 2.10 Car Ford; // Car is a struct type. "Smith.name" means Smith's name. "Smith.age" means Smith's age. "Ford.price" means Ford's price. "Ford.size" means Ford's size. "Ford.color" means Ford's color. "Ford.color" means Ford's color.

Example 2.12 using System; namespace structSample{ struct Student{ // defines a struct type public int id; // struct field public string name; // struct field public int age; // struct field } class Program{ static void Main(string[] args){ Student Smith; // struct variable Smith.id = 1001; Smith.name = "Andy"; Smith.age = 16; Console.WriteLine("Smith's id is " + Smith.id); Console.WriteLine("Smith's name is " + Smith.name); Console.WriteLine("Smith's age is " + Smith.age); Console.ReadLine(); } } } Example 2.13 enum Week { // defines an enum type Sunday, // enum member Monday, // enum member Tuesday, // enum member }; Example 2.14 Week w; // Week is an enum type, w is an enum variable Example 2.15 "Today.Morning" means Today's Morning. "Today.Afternoon" means Today's Afternoon. "Today.Evening" means Today's Evening. "Week.Sunday" means Week's Sunday. "Week.Monday" means Week's Monday. "Week.Tuesday" means Week's Tuesday.

Example 2.16 using System; namespace enumExample{ public enum Today{ // defines an enum type morning, // enum member afternoon, // enum member evening, // enum member } class Program{ static void Main(string[] args){ Today t0, t1, t2; // defines enum varialbes t0 = Today.morning; t1 = Today.afternoon; t2 = Today.evening; Console.WriteLine("Have a breakfast in " + t0); Console.WriteLine("Have a lunch in " + t1); Console.WriteLine("Have a supper in " + t2 ); Console.ReadLine(); } } } Chapter3 Example 3.1 using System; namespace IfStatement{ class Program{ static void Main(string[] args){ int a = 200; int b = 100; if (a > b){ Console.WriteLine("a is greater than b."); Console.ReadLine(); }}}} Example 3.2 using System; namespace IfelseStatement{ class Program{ static void Main(string[] args){ int a = 100; int b = 200; if (a > b){ Console.WriteLine("a is greater than b."); Console.ReadLine(); } else { Console.WriteLine("a is less than b."); Console.ReadLine(); }}}} Example 3.3 using System; namespace SwichStatement{ class Program{ static void Main(string[] args){ int number = 20; switch (number){ case 10: Console.WriteLine("Running case 10"); Console.ReadLine(); break; case 20: Console.WriteLine("Running case 20"); Console.ReadLine(); break; case 30: Console.WriteLine("Running case 30"); Console.ReadLine(); break; default: Console.WriteLine("Running default code"); Console.ReadLine(); break; }}}} Example 3.4 using System; namespace ForStatement{ class Program{ static void Main(string[] args){ for (int x = 0; x <= 5; x++){ Console.Write(x); } Console.ReadLine(); }}} Example 3.5 using System; namespace WhileStatement{ class Program{ static void Main(string[] args){ int counter = 0; while (counter < 8) { Console.Write("&"); counter++; } Console.ReadLine(); }}} Example 3.6 using System; namespace DoWhileStatement{ class Program{ static void Main(string[] args){ int counter = 0; do{ Console.Write("@"); counter ++; } while (counter < 8); Console.ReadLine(); }}} Example 3.7 using System; namespace BreakStatement{ class Program{ static void Main(string[] args){ int num = 0; while (num < 10){ if (num == 5) break; num++; } Console.Write(num); Console.ReadLine(); }}} Example 3.8 using System; namespace ContinueStatement{ class Program{ static void Main(string[] args){ int num = 0; while (num < 10){ num++; if (num == 5) continue; Console.Write(num); } Console.ReadLine(); }}} Example 3.9 using System; namespace InputDemo{ class Program{ static void Main(string[] args){ string name; Console.Write("Enter your name:"); name = Console.ReadLine(); // accept user input Console.WriteLine(name); Console.ReadLine(); }}} Chapter4 Example 4.1 using System; namespace stringLength{ class Program{ static void Main(string[] args){ string str = "JavaScript"; int num = str.Length; Console.WriteLine(num); Console.ReadLine(); }}} Example 4.2 using System; namespace substringExample{ class Program{ static void Main(string[] args){ string str = "JavaScript"; string myString = str.Substring(4, 6); Console.WriteLine(myString); Console.ReadLine(); }}} Example 4.3 using System; namespace replaceString{ class Program{ static void Main(string[] args){ string str1 = "JavaScript in 8 Hours"; string str2 = str1.Replace("JavaScript", "AngularJS"); Console.Write(str2); Console.ReadLine(); }}} Example 4.4 using System; namespace InsertString{ class Program{ static void Main(string[] args){ string str1 = "Java in 8 Hours"; string str2 = str1.Insert(4, "Script"); Console.WriteLine(str2); Console.ReadLine(); }}} Example 4.5 using System; namespace InsertString{ class Program{ static void Main(string[] args){ string str1 = "JavaScript in 8 Hours"; string str2 = str1.Remove(4, 6); Console.WriteLine(str2); Console.ReadLine(); }}} Example 4.6 int [ ] myArray = { 10,20,30,40 }; Example 4.7 int [ ] myArray = new int [3]; myArray [0] = 100; myArray [1] = 200; myArray [2] = 300; Example 4.8 using System; namespace CreatArray1{ class Program{ static void Main(string[] args){ int[] myArray = { 10, 20, 30, 40 }; int num = myArray.Length; Console.WriteLine(num); Console.ReadLine(); }}} Example 4.9 int [ ] arr = {10, 20, 30, 40, 50}; int value = arr[2]; Console.WriteLine( value ); ( Output: 30) Example 4.10 int [ ] num = new int [5]; num[2] = 800; Console.WriteLine(num[2]); ( Output: 800) Example 4.11 using System; namespace foreachStatement{ class Program{ static void Main(string[] args){ string [ ] arr = {"A ", "B ", "C "}; foreach (string var in arr) Console.Write(var); Console.ReadLine(); }}} Example 4.12 using System; namespace sortArray{ class Program{ static void Main(string[] args){ String [ ] arr = { "Cat ", "App ", "Dog ", "Boy "}; Array.Sort (arr); foreach (String var in arr){ Console.Write(var); } Console.ReadLine(); }}} Chapter 5 Example 5.1 using System; namespace functionExample{ class Program{ static void myFunction(){ // function declaration Console.Write("This is a function example."); Console.ReadLine(); } static void Main(string[] args){ myFunction(); // call function } } } Example 5.2 using System; namespace functionExample{ class Program{ static void myFunction(string arg){ // function declaration Console.Write(arg); Console.ReadLine(); } static void Main(string[] args){ String str = "A function with argument."; myFunction(str); // call function with argument } } } Example 5.3 using System; namespace returnExample{ class program{ static int add(int num1, int num2){ // retern type is int return num1 + num2; // return value to caller } static void Main(){ int result = add(3,5); Console.WriteLine("3 + 5 = " + result); Console.ReadLine(); } } } Example 5.4 int a, b=0; a=100/b; // exception occurs Example 5.5 using System; namespace trycatch{ class Program{ static void Main(string[] args){ int a, b = 0; try{ a = 100 / b; // exception occurs } catch (Exception ex){ Console.WriteLine(ex.Message); // exception message Console.ReadLine(); }}}} Example 5.6 using System; namespace trycatch{ class Program{ static void Main(string[] args){ try{ string str1 = "Java in 8 Hours"; string str2 = str1.Insert(100, "Script"); // 100 cause exception } catch (Exception ex){ Console.WriteLine(ex.Message); } finally { Console.WriteLine("Exception has been handled!"); Console.ReadLine(); }}}} Example 5.7 using System; namespace trycatch{ class Program{ static void Main(string[] args){ try{ int a, b = 0; if (b == 0){ throw new Exception("b is zero, Exception ocurred!"); } a = 100 / b; } catch (Exception ex){ Console.WriteLine(ex.Message); // exception message Console.ReadLine(); } } } } Example 5.8 using System; using System.Collections.Generic; namespace ListDemo{ class Program{ static void Main(string[] args){ List MyList = new List{10,11,12,13}; Console.Write(MyList[0] +" "); Console.Write(MyList[1] +" "); Console.Write(MyList[2] +" "); Console.Write(MyList[3] +" "); Console.ReadLine(); }}} Example 5.9 using System; using System.Collections.Generic; namespace ListDemo{ class Program{ static void Main(string[] args){ List MyList = new List{10,11,12,13}; MyList.Add(14); // now becomes {10,11,12,13,14} MyList.Insert(3,100); // now becomes {10,11,12,100,13,14} MyList.IndexOf(100); // returns index 3 MyList.Reverse(); // now becomes {14,13,100,12,11,10} MyList.Remove(100); // now becomes {14,13,12,11,10} Console.Write(MyList.Count); // now has five elements Console.ReadLine(); }}} Chapter6 Example 6.2 using System; namespace ClassAndObject{ class Program{ public class Color{ // declares a class Color public string c1; // property member public string c2; // property member public void brightness( ){ // method member Console.WriteLine("The color of this flower is "+ c1); Console.WriteLine("The color of that flower is "+ c2); Console.ReadLine(); }} static void Main(string[] args){ Color obj = new Color( ); // create an object obj obj.c1="yellow"; // object references a variable obj.c2="purple"; // object references a variable obj.brightness ( ); // object refereces a method }}} Example 6.3 using System; namespace ClassAndObject{ class Program{ public class Color{ // declares a class Color public string c1; // property member public string c2; // property member public Color( ){c1="yellow"; c2="purple";} // constructor public void brightness(){ // method member Console.WriteLine("The color of this flower is " + c1); Console.WriteLine("The color of that flower is " + c2); Console.ReadLine(); }} static void Main(string[] args){ Color obj = new Color(); //create an object obj,call constructor obj.brightness(); // object refereces a method }}} Example 6.4 public class Color { // define a class String c1, c2; Color ( ) { c1="yellow"; c2="purple"; } // constructor ~ Color ( ); // This is a destructor. } Example 6.5 using System; namespace Overloading{ class Color{ // declare a class "Color" String x, y; // declare two variable members Color( String a, String b) { x = a; y = b; } // constructor Color() { x = "yellow "; y = "purple "; } // constructor static void Main(string[] args){ Color obj1=new Color("green ", "orange "); Color obj2=new Color( ); Console.WriteLine(obj1.x + obj1.y); Console.WriteLine(obj2.x + obj2.y); Console.ReadLine(); }}} Example 6.6 using System; namespace thisExample{ class MyClass{ int num; void test(int num){ this.num = num; // this represents the current object Console.Write(this.num); } static void Main(string[] args){ MyClass obj = new MyClass( ); // create an object "obj" obj.test(10); Console.ReadLine(); }}} Example 6.7 class Computer { // this is a base class // base class member } class Laptop: public Computer { // inheritance // derived class member } Example 6.8 using System; namespace inheritance{ public class program{ class Computer{ // declare a base class public void display(){ Console.WriteLine("Computer OK"); Console.ReadLine(); } } class Laptop : Computer{ // inheritance // derived class's member in here } static void Main(string[] args){ Laptop Lt = new Laptop(); // derived class creates an object Lt Lt.display(); // Lt calls base class's method } } } Example 6.9 using System; namespace Overriding{ class Program{ class Computer{ // base class public void harddrive( ){ Console.WriteLine("5T"); } public void memory() { Console.WriteLine("4G"); Console.ReadLine();} } class Laptop: Computer{ // derived class public void harddrive() { Console.WriteLine("10T"); } public void memory() { Console.WriteLine("8G"); Console.ReadLine(); } } static void Main(string[] args){ Laptop myLaptop = new Laptop() ; // creates an object myLaptop.harddrive( ); myLaptop.memory( ); }}} Chapter7 Example 7.1 using System; namespace PublicModifier{ class PublicDemo{ public int a; // declare a public variable public int b; // declare a public variable } class Program{ static void Main(string[] args){ PublicDemo obj = new PublicDemo(); obj.a = 100; // access the public member obj.b = 200; // access the public member Console.WriteLine("a=" + obj.a); Console.WriteLine("b=" + obj.b); Console.ReadLine(); } } } Example 7.2 using System; namespace PrivateModifier{ class privateDemo{ private int a; // declare a private variable private int b; // declare a private variable } class Program{ static void Main(string[] args){ privateDemo obj = new privateDemo(); obj.a = 100; // access the private member obj.b = 200; // access the private member Console.WriteLine("a=" + obj.a); Console.WriteLine("b=" + obj.b); Console.ReadLine(); }}} Example 7.3 using System; namespace PrivateModifier{ class PrivateDemo{ private int a = 100; // declare a private variable private int b = 200; // declare a private variable public void accessVariable(){ Console.WriteLine("a = " + a); // access private variable Console.WriteLine("b = " + b); // access private variable Console.ReadLine(); }} class Program{ static void Main(){ PrivateDemo obj = new PrivateDemo(); obj.accessVariable(); // call the public method }}} Example 7.4 using System; namespace ProtectedModifier{ class A{ protected int p = 100 ; // declare a protected variable } class B : A{ static void Main(){ A a = new A(); // creat an object of base class Console.WriteLine(a.p); // access protected variable Console.ReadLine(); }}} Example 7.5 using System; namespace ProtectedModifier{ class A{ protected int p = 100 ; // declare a protected variable } class B : A{ static void Main(){ B b = new B(); // creat an object of derived class Console.WriteLine(b.p); // access protected variable Console.ReadLine(); }}} Example 7.6 using System; namespace ProtectedDemo{ class protectedDemo{ protected int a = 800; // declare a protected variable protected int b = 1000; // declare a protected variable protected int sum; // declare a protected variable public void accessVariable(){ sum = a + b; // access the protected variables Console.WriteLine("a + b = " + sum); Console.ReadLine(); }} class Program{ static void Main(){ protectedDemo obj = new protectedDemo(); obj.accessVariable(); // call the public method }}} Example 7.7 using System; public class Lottery{ private int number; public int LuckyNumber{ // create an accessor get{ return number; } set{ number = value; }} public void print(){ Console.WriteLine("Lucky Number is: " + number); Console.ReadLine(); }} public class MainClass{ public static void Main(){ Lottery lot = new Lottery(); lot.LuckyNumber = 16888; // reference the accessor lot.print(); }} Example 7.8 using System; using System.Collections.Generic; using System.Linq; namespace LinqDemo{ class IntroToLINQ{ static void Main(){ int[] MyArray = new int[6] { 10, 15, 20, 25, 30, 35}; var myQuery = // myQuery is a variable from item in MyArray // create a linq where (item % 10) == 0 select item; foreach (int item in myQuery){ Console.Write(item + " "); } Console.ReadLine(); }}} Example 7.9 using System; public delegate int DelegateFun(int a, int b); // declare a delegating function DelegateFun. class Program{ static int Sum(int a, int b) => // this is a delegated function Sum, its arguments should be the same as the arguments of the delegating function DelegateFun() a + b; // this is the delegated funtction body public static void Main(string[] args){ DelegateFun delegateObj = new DelegateFun(Sum); // create a delegate object delegateObj, its argument should be the delegated function name Sum Console.WriteLine("100 + 2 = " + delegateObj(100, 2)); // call the delegated function Sum , and pass arguments Console.ReadLine(); } } Example 7.10 using System; class Program{ public delegate int DelegateFun(int a, int b); // declare delegating function DelegateFun() public static int Division(int a, int b){ // delegated function return a / b; } public static int Multiply(int a, int b){ // delegated function return a * b; } public static int Subtract(int a, int b){ // delegated function return a - b; } public static void Main(string[] args){ // create delegate objects DelegateFun delegateObj1 = new DelegateFun(Division); DelegateFun delegateObj2 = new DelegateFun(Multiply); DelegateFun delegateObj3 = new DelegateFun(Subtract); Console.WriteLine("100 / 2 = " + delegateObj1(100, 2)); // call Console.WriteLine("100 * 2 = " + delegateObj2(100, 2)); // call Console.WriteLine("100 - 2 = " + delegateObj3(100, 2)); // call Console.ReadLine(); }} Chapter8 Example 8.1 using System; namespace AbstractDemo{ abstract class Books{ // define an abstract class public abstract void read(); // declare an abstract method } class eBooks:Books{ // class eBooks extends class Books public override void read(){ // override abstract method Console.Write("Overrides the abstract method!"); }} class Program{ static void Main(string[] args){ eBooks b = new eBooks(); b.read(); Console.ReadLine(); }}} Example 8.2 using System; namespace InterfaceDemo{ interface Books{ // define an interface void booksNumbers(); // define an empty method } class eBooks : Books{ // implement the interface public void booksNumbers(){ // implement the empty method Console.WriteLine("Implement the empty method!"); }} class Program{ static void Main(string[] args){ eBooks obj = new eBooks(); obj.booksNumbers(); Console.ReadLine(); }}} Example 8.3 using System; namespace StaticVariable{ class MyClass{ public static int num =100; // define a static variable static void Main(string[] args){ Console.Write(MyClass.num); // class references a variable Console.ReadLine(); } } } Example 8.4 using System; namespace StaticVariable{ class MyClass{ public static int myMethod() { return 200;} // define a static method static void Main(string[] args){ Console.Write(MyClass.myMethod()); // class references the method Console.ReadLine(); } } } Example 8.5 using System; namespace PolymorphismDemo{ class Program{ class Animal{ virtual public void cry( ){ // defines a virtual method Console.WriteLine("crying......"); }} class Dog:Animal{ public override void cry( ){ // overrides the virtual method Console.WriteLine("Wow, Wow......"); }} class Cat:Animal{ public override void cry( ){ // overrides the virtual method Console.WriteLine("Meow, Meow......"); Console.ReadLine(); }} static void Main(string[] args){ Animal animalVar; animalVar = new Dog( ); animalVar.cry( ); animalVar = new Cat( ); animalVar.cry( ); }}} Example 8.6 using System; using System.Text; using System.IO; namespace WriteFile{ class WriteTextFile{ static void Main(){ string myText = "VB in 8 Hours"; StreamWriter file = new StreamWriter("D:\\myFile.txt", true); file.WriteLine(myText); // write the text to the file file.Close(); }}} Example 8.7 using System; using System.Text; using System.IO; namespace ReadFile{ class Program{ static void Main(string[] args){ String myText; StreamReader file = new StreamReader("D:\\myFile.txt"); myText = file.ReadLine(); //read the first text while (myText != null){ //read until reach end of file Console.WriteLine(myText); myText = file.ReadLine(); //read the next text } file.Close(); Console.ReadLine(); }}}

Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Computer Coding»

Look at similar books to Computer Coding. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «Computer Coding»

Discussion, reviews of the book Computer Coding and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.