Core Programmingนายสมเกียรติ สอนนวลCimatt Business Group Co.,LTD.
Core ProgrammingUnderstand computerstorage and data typesUnderstand computerdecision structuresIdentify the appropriatemethod for handlingrepetitionUnderstand errorhandling
Understand computerstorage and data typesLesson OverviewStudents will understand computer storage and data types.In this lesson, you will learn:How a computer stores programs and instructions in computer memoryMemory stacks and heapsMemory size requirements for the various data storage typesNumeric data and textual data
Understand computerstorage and data typesReview TermsData type—a definition of a set of data that specifies the possiblerange of values of the set, the operations that can be performedon the values, and the way in which the values are stored inmemory.Garbage collection—a process for automatic recovery of heapmemory.Heap—a portion of memory reserved for a program to use for thetemporary storage of data structures whose existence or sizecannot be determined until the program is running.Memory —a device where information can be stored andretrieved.Stack—a region of reserved memory in which programs storestatus data such as procedure and function call addresses, passedparameters, and sometimes local variables.
Understand computerstorage and data typesHow a computer stores programs in memoryA computer keeps data and programs in storage as follows:Primary storage—Otherwise known as random access memory(RAM), it is made of memory chips. In common usage, it refersonly to a computer’s main memory, the fast semiconductorstorage (RAM) directly connected to the processor.Secondary storage—Otherwise known as a hard drive, itconsists of a read/write head that floats above rotating platterscoated with a magnetic material.
Understand computerstorage and data typesMemory–Stacks and HeapsVariables are stored in either a stack or heap based on their type:Value types (e.g.: int, double, float) go on the stack.Reference types (String, Object) go on the heap.* Value types in classes are stored with the instance of the class onthe heap.The stackValues in the stack are managed without garbage collectionbecause items are added and removed from the stack as last in,first out (LIFO) every time you enter or exit a scope, like a methodor statementA StackOverFlowException occurs because you have usedup all the available space in the stack.
Understand computerstorage and data typesMemory–Stacks and Heaps (continued)The heapA heap-based memory allocation occurs when we create a newobject, at which point the compiler figures out how much memoryis needed and allocates an appropriate amount of memory spaceand returns a reference representing the memory address.A heap is used for dynamic allocation of memory.The Microsoft .NET Framework uses garbage collection to free upspace during run time.Garbage collection is an automatic process for recovery of heapmemory. Blocks of memory that had been allocated but are nolonger in use are freed, and blocks of memory still in use may bemoved to consolidate the free memory into larger blocks.
Understand computerstorage and data typesstring :  textstring fileName = “TheXFile.avi”;string name = “somkiet”;string message = “Warnning : \n Some errors occure.”;
Understand computerstorage and data typesData TypesNumeric data typesIntegral types (e.g.: byte, char, int)Floating-point types (float, double)DecimalBooleanExample: bool done = false;
Understand computerstorage and data typesIntegral Types
Understand computerstorage and data typesFloating-Point Types
Understand computerstorage and data typesDecimal Type
Understand computerstorage and data typesUsing the Numeric Data Typesbyte numKids = 15;char letter = ‘p’;intworldPopulation = 6692030277;float money = 201.00f;double lotsaMoney = 2.4E+12;
Understand computerstorage and data typesLesson ReviewDescribe how the program statement below is stored in memory:inttennisPoints = 30;Identify the appropriate data types for each of the following values.4233423.93100-2323true
Assignmentdouble num = 2;String ohSnap = "%$^&$ ";int num2 = 10.9;byte smallNum = -42;char word = 'word';long bigNum = 12345678.9;float x = 3.5F;decimal deciNum = 4.2m;
Answerdouble num = 2;String ohSnap = "%$^&$ ";int num2 = 10.9;byte smallNum = -42;char word = 'word';long bigNum = 12345678.9;float x = 3.5F;decimal deciNum = 4.2m;

1.1 core programming [understand computer storage and data types]

  • 1.
  • 2.
    Core ProgrammingUnderstand computerstorageand data typesUnderstand computerdecision structuresIdentify the appropriatemethod for handlingrepetitionUnderstand errorhandling
  • 3.
    Understand computerstorage anddata typesLesson OverviewStudents will understand computer storage and data types.In this lesson, you will learn:How a computer stores programs and instructions in computer memoryMemory stacks and heapsMemory size requirements for the various data storage typesNumeric data and textual data
  • 4.
    Understand computerstorage anddata typesReview TermsData type—a definition of a set of data that specifies the possiblerange of values of the set, the operations that can be performedon the values, and the way in which the values are stored inmemory.Garbage collection—a process for automatic recovery of heapmemory.Heap—a portion of memory reserved for a program to use for thetemporary storage of data structures whose existence or sizecannot be determined until the program is running.Memory —a device where information can be stored andretrieved.Stack—a region of reserved memory in which programs storestatus data such as procedure and function call addresses, passedparameters, and sometimes local variables.
  • 5.
    Understand computerstorage anddata typesHow a computer stores programs in memoryA computer keeps data and programs in storage as follows:Primary storage—Otherwise known as random access memory(RAM), it is made of memory chips. In common usage, it refersonly to a computer’s main memory, the fast semiconductorstorage (RAM) directly connected to the processor.Secondary storage—Otherwise known as a hard drive, itconsists of a read/write head that floats above rotating platterscoated with a magnetic material.
  • 6.
    Understand computerstorage anddata typesMemory–Stacks and HeapsVariables are stored in either a stack or heap based on their type:Value types (e.g.: int, double, float) go on the stack.Reference types (String, Object) go on the heap.* Value types in classes are stored with the instance of the class onthe heap.The stackValues in the stack are managed without garbage collectionbecause items are added and removed from the stack as last in,first out (LIFO) every time you enter or exit a scope, like a methodor statementA StackOverFlowException occurs because you have usedup all the available space in the stack.
  • 7.
    Understand computerstorage anddata typesMemory–Stacks and Heaps (continued)The heapA heap-based memory allocation occurs when we create a newobject, at which point the compiler figures out how much memoryis needed and allocates an appropriate amount of memory spaceand returns a reference representing the memory address.A heap is used for dynamic allocation of memory.The Microsoft .NET Framework uses garbage collection to free upspace during run time.Garbage collection is an automatic process for recovery of heapmemory. Blocks of memory that had been allocated but are nolonger in use are freed, and blocks of memory still in use may bemoved to consolidate the free memory into larger blocks.
  • 8.
    Understand computerstorage anddata typesstring : textstring fileName = “TheXFile.avi”;string name = “somkiet”;string message = “Warnning : \n Some errors occure.”;
  • 9.
    Understand computerstorage anddata typesData TypesNumeric data typesIntegral types (e.g.: byte, char, int)Floating-point types (float, double)DecimalBooleanExample: bool done = false;
  • 10.
    Understand computerstorage anddata typesIntegral Types
  • 11.
    Understand computerstorage anddata typesFloating-Point Types
  • 12.
    Understand computerstorage anddata typesDecimal Type
  • 13.
    Understand computerstorage anddata typesUsing the Numeric Data Typesbyte numKids = 15;char letter = ‘p’;intworldPopulation = 6692030277;float money = 201.00f;double lotsaMoney = 2.4E+12;
  • 14.
    Understand computerstorage anddata typesLesson ReviewDescribe how the program statement below is stored in memory:inttennisPoints = 30;Identify the appropriate data types for each of the following values.4233423.93100-2323true
  • 15.
    Assignmentdouble num =2;String ohSnap = "%$^&$ ";int num2 = 10.9;byte smallNum = -42;char word = 'word';long bigNum = 12345678.9;float x = 3.5F;decimal deciNum = 4.2m;
  • 16.
    Answerdouble num =2;String ohSnap = "%$^&$ ";int num2 = 10.9;byte smallNum = -42;char word = 'word';long bigNum = 12345678.9;float x = 3.5F;decimal deciNum = 4.2m;