Posts

Showing posts from August, 2022

Programming Concepts Part III

  Continuing from Programming Concepts Part II . A computer cannot understand instructions as given in the previous part. We have to change those human-understandable instructions to machine-understandable instructions. It is known as the machine language of the computer. A computer only understands a sequence of 0s and 1s. Most of the time we see mention of the 0 and the 1. But we can also say yes/no, on/off, true/false and so on. There are two states, either present or absent. All numbers, texts, images and so on are a sequence of 0s and 1s. There are two states or symbols(0 and 1), so it is called a binary system . A single 0 or 1 is called a bit for a binary digit. Its counting goes like this, 1 = 1 10 = 2 11 = 3 100 = 4 101 = 5 110 = 6 111 = 7 1000 = 8 1001 = 9 1010 = 10 1011 = 11 1100 = 12 1101 = 13 1110 = 14 1111 = 15 and so on. The place value is like 1, 2, 4, 8, 16, 32 and so on from right to left. When the number of bits is large, it is grouped in 3 bits from the right ...

Programming Concepts Part II

Continuing from Programming Concepts Part I , now we talk about real programming tasks.   As we need containers to put items in a kitchen. Then we use these items to prepare food for ourselves. The preparation of food involves some activity. In the same manner, in programming, we need variables to store values and we do some activity to complete a task. We use instructions to complete a task. For example, we need two variables to store values and addition instruction (+) to find the sum of the two variables. In a high-level programming language, we say instructions as operators . a = 5 b = 8 a + b is 13   The first time when we introduce a variable in a program it is called the declaration of the variable. And the first-time value assigned to the variable is called initialization of the variable.   Each programming language has its own way of variable declaration and initialization. In this series, we are going to learn the fundamentals of computer programming. Langua...

Programming Concepts Part I

 In this series, we are going to learn the fundamentals of computer programming. Language-specific features will be provided in a different series.   A programming language is one of the possible ways to instruct a computer. We try to solve a real-life problem. Every programming language might not be suitable for the current problem at hand.         In other words, we can say that programming is the skill of implementing an algorithm in a programming language. An algorithm is a step-by-step solution for a problem. So, we can not solve a moderate-size problem in one step. We need to break down a problem into problems of a manageable size. The person who does programming is known as a programmer. Some programmers deal with computer hardware and they are known as system programmers. Others are known as web programmers and write web applications. So, the different types of developers(programmers) use different programming languages to handle thei...

Variable Declaration Using var Block and := In golang

In this article, we will learn about how to declare multiple variables in a declaration block. And we can also use := to declare a variable. As we see on lines 5-7 that every variable declaration is, we start with the var keyword and then provide variable name and then end with the type of the variable. We can also initialize variables using the assignment operator = and providing the value on the right hand side as follows,  var name string = "John" The same thing has been done on lines 10-14. In this case, every variable declaration is not preceded by the var keyword rather all variables are inside a var block. If we remove comments on lines 5-7, it will be not effective inside the main function due to re-declaration of the same variables. It is called shadowing. It means values assigned inside the main function will be effective. We can also use var block outside any function. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 package main import ...