Basics of Computer 2 (data)

How programs run in computer is such a question which if answered properly will surprise you.

     From a-z all applications (including games, multimedia data) run on numeric data. And it's not even very complex data either. Just integral and decimal data with basic functions that are performed on it by processor (+, -, *, /) that we learned in previous session. So don't worry if someone tells that programming is hard. It's just coding as i explained in introduction to coding.
     So what is computer data? People ofter say or hear that computer only works on 0's and 1's. And obviously it's not very much the same data what we actually encounter while using computer. Here is how data is handled in computers as well as all electronic devices.
     Computer data is called binary data. Binary means pair like pair of 0 and 1. This is similar to normal mathematical decimal data in which we have 10 basic terms being 0,1,2,3 . . . 9. When we combine binary terms we get different combinations which can be measured by taking number of binary digits to the power of 2 because there are 2 possible terms in a binary digit.
     Hence if we need 2 combinations we will need 1 digit. If we need 4 we take 2 digits. 8 in 3, 16 in 4 and it goes up to 256 in 8 binary digits. The binary digits are called bits and 8 binary digit combined are called byte which is basic unit of binary data. Data is stored in combinations in bytes that's why we read it as kilo-byte , mega-byte, giga-byte and so on.
     But still these combinations are not actual values like 10,22,393. So we translate these values in normal decimal values byte by byte. Hence we define 256 combinations with all symbols that are basic and we need them to show data. These symbols were defined to decode binary language into commonly used language. You can see this table table to get a more clear idea and all symbols of computer.
DATA:
     Computer programs use 2 basic kind of data. Numeric data and character data. Numaric data involves integers and decimals. Character data involves English characters and symbols. In computer data is stored in primitive data types. These are data types that are standard in every language and can store basic data of computer. These include:
    • integer       (fixed size 4 byte - integral whole number values)
    • long           (fixed size 8 byte - integral whole number values - greater then integer)
    • float           (fixed size 4 byte - decimal values)
    • double        (fixed size 8 byte - decimal values - greater then float)
    • boolean      (basic bit value - 0 or 1 - also known as true or false)
    • character    (fixed size 1 byte - contains one symbol from 256 ASCII combinations)  
     By combining theses basic types we make all the data that is available in computer for example:
    • string          (non-primitive - combination of character data type to represent words, lines)
     Hence programmer can use computer memory by these data types.

Let's take some practical example
Example: Make a program which can store data of a students of these fields ( name, section, registration number, class percentile)
Solve:
  1. First you will make code which is to simplify program functions. Like program has to ask user to enter some data, then it has to store that data and also it will need to show it.
  2. Second you will specify the code according to computer functionality. In this case we have to define what kind of data we need to store and how to store it.
    • First data is name, which is combination of characters hence we need combinations of characters to store this kind of data.
    • Then we have section of student. Which can be represented by a single character so we use character.
    • Third we need to store registration number which is in integral form so we use int.
    • And in last we need to store percentile which is a decimal (but small) value so we use float.
And this is all basic information that is required to get started with programming.

Comments

Popular posts from this blog

C++ Console : Basic Graphic Techniques

C++ Console : Change Font Size

C++ Console : Color