Computer Science
programming concepts

Whenever computers are mentioned, we think about personal computers (PCs) and desktops. However, computers can refer to a range of devices including TVs, consoles, cameras, smartphones, etc. that perform specific tasks. A computer at its core is not as smart as the average user thinks.

Computers need to be given specific instructions to carry out. If no input is given by the user, the computer will sit idle and not do anything. The set of instructions given to the computer to perform specific tasks is called a program.

As humans, we communicate in different languages like English, French, Spanish, etc. For example, if you only speak English and want to have a conversation with a man that speaks only Spanish, you will need an interpreter that would translate the conversation. This is similar to what happens whenever we use computers.

Computers operate on machine code which is a series of binary codes i.e. 0s (zeros) and 1s (ones) that can be interpreted quickly by the computer. Even if we could understand machine code, it would take a long time to give instructions to the computer to carry out. The process of giving instructions to the computer is called programming and several programming languages exist.

Programming languages act as an intermediary between programmers and computers as they are easier for humans to learn and understand than machine code. Programming languages use human-readable code that contains a set of instructions specified by the programmer and interprets it to the computer in machine code.

In this article, we will give a brief introduction to programming concepts for beginners as programming fundamentals are the building blocks of all programming languages and are essential for learning any programming language.

Programming Concepts for Beginners

Programming concepts are the fundamental principles that govern all programming languages and their various applications. There are various computer programming concepts and applications that cut across various programming languages but for this article, we would discuss major concepts that aid in understanding programming, and which apply to all programming languages.

Variables

Variables are a system of data storage for different types of data so that they can be manipulated when needed in the program. For example, we can consider a store keyholder i.e. someone who holds the key to a store as a variable and the key as the data stored in the variable.

Variables have different types depending on the type of data they contain; strings (alphabetic characters A-Z), integers (whole numbers  1,2,3…), floats (decimal numbers with fewer digits 0.1,27.12,2.3576…) or doubles (decimal numbers with more digits 0.1569887687,1.233397698762…).

Variables are the backbone of any programming language and are created using the declaration specific to the programming language being used. Variables are created by first specifying the data type and then declaring it in key-value pairs where the key is the variable name, and the value is the data value it contains. For example, in C programming, a variable can be declared like this:

dataType variableName = dataValue;

int myAge  = 18; or char myName = Emmanuel;

int stands for integer and char stands for character, they both represent the type of data stored in the variable. myAge and myName are the names of the variables. ’18’ and ’Emmanuel’ are the values stored in the variables.

Note that each line of code is separated by semi-colons.

Variables contain a set of data values that change depending on instructions given in the program and the variable names are used to reference or refer to the variable anywhere in the program.

Control Structures

Control Structures are core components of programming that allow the programmer to control the flow of information within a program based on specific conditions. They enable the program to make decisions like repeat tasks or execute different portions of code based on predefined conditions.

Traffic lights use control structures to set the countdown to when the colour changes from one colour to another and also ensure that it shows only one light at a time. There are three basic types of flow control structures and they are explained below.

  • Sequential Control Structure


This is the most basic form of control structure. It is the default flow of a computer program where the program runs the set of instructions sequentially from the start till it reaches the end. Each instruction is run according to the way they appear in the program with no repetitions of code based on any condition.

Here, the program follows a linear path in executing instructions from the start till the end which limits the program’s flexibility as different conditions in a program may need different instructions to be executed.

  • Selection Control Structure or Conditional Statements


In this control structure, the programmer writes the code to make the program check a condition and then specifies the action to perform if the condition equals true or false. Considering the traffic example, the program can use a selection control structure to ensure that immediately after one traffic light changes, the surrounding traffic lights change in sync to avoid accidents.

Here, the program evaluates a condition and then executes the appropriate block of code as assigned by the programmer. These are the most common types of conditional statements in programming languages:

  1. If Statements
  2. If – Else statements
  3. Else if statements
  4. Switch Statements
  • Iteration Control Structure or Loops


This programming concept allows a set of instructions to be executed repeatedly as long as a specified condition is true. In the traffic light example, an iteration control structure can be used to keep only one light on at a time. It will set the conditions such that when one light is on, another does not come on.

An iteration control structure is used to carry out a task repetitively based on a specified logical condition; this repetition is called a loop in computer programming. A loop is made up of the condition and the code to execute. These are common types of Loops:

  1. While loop
  2. For loop
  3. Do-while loop
Data Structures 

This is defined as a way of storing and organizing data in a computer so that it can be used and referenced efficiently in a program. Data structures allow programmers to control data collection, especially in large amounts. Imagine a collection of names of people who have read this article and 100 people who have read it.


If we stored each of the names in different variables, we would have to reference all of them making the program cumbersome and harder to manipulate. To avoid this and increase the flexibility of the program, programmers could use data structures to sort all related variables. 

Here, we would use a List data structure to contain the list of names in a single variable which makes referencing and maintaining the code easier. Some types of data structures are Arrays, Linked lists, Stacks, Trees and Graphs.

Functions 

Functions are blocks of organized code that perform a specific task and can be used anywhere in the program after it is defined once. Functions have to be called before they are executed; to do this we write the name of the function followed by parentheses (). A function could also have one or more parameters placed inside the parentheses separated by commas and ended with a semicolon.


Functions make programs easier to manage and understand. Some functions are provided by the programming language called built-in functions and custom functions which are defined to meet exactly the specification of the programmer. In C programming, there must be at least one main function (). In C programming the following is a built-in function.

printf(”Hello World”); is a built-in function,

The following is a custom function that takes 2 numbers as parameters and calculates the sum.

int addNumbers( int a, int b){

return(a+b);

}

Syntax

All programming languages have their special way of writing computer code unique to each of them, this is known as syntax. Syntax in programming is a set of rules that define a particular layout of code in a way that the computer interprets and executes the code accurately. Understanding the syntax is essential to learning any programming language.

Both examples of declaring variables and creating functions implement C programming syntax. If the rules of syntax specific to a language are not followed the program would break (display an error) or not do what it was originally programmed to do. 

Tools

Tools in programming are the software that is used to write or develop programs faster. There are different tools available for all programming languages such as an IDE. An IDE or Integrated Development Environment is a piece of software that checks the syntax of code for errors, organizes files and helps with easy navigation through code.


IDEs act as both a source code editor and compiler as it allows developers to edit code and also translate the code to machine-readable code The process of translating the programming language to binary code is known as compiling. CodeBlocks is an example of an IDE used in C programming.

Debugging

Debugging is the process of finding and fixing errors or bugs in a program. It is essential to programming as all programs contain errors or can be optimized (using fewer lines of code to execute a function). There are different techniques used in debugging that account for the creation of more accurate and error-free code.

Algorithms

Algorithms are a set of structured instruction that when followed accurately, completes a specific task. It is a procedural programming concept that is used to solve problems and manipulate data in a program. Algorithms should be designed to be precise, efficient and easily understandable by other programmers.

An example of an algorithm is a course curriculum; it gives specific topics to learn to master the course. Programmers employ algorithm design to create efficient and effective programs that systematically solve complex problems. 

Key Points

  • Programming refers to the process of writing instructions for a computer to perform specific tasks.
  • Programming languages act as an intermediary between humans and computers by using human-readable code that the computer can translate into machine code.
  • Programming concepts include variables, control structures (sequential, conditional, and loops), data structures, functions, syntax, and tools.
  • Control structures enable the program to make decisions based on conditions. 
  • Functions perform specific tasks using syntax specific to the programming language.

FAQ

  • What are programming concepts?

Programming concepts are the fundamental principles that govern all programming languages and their applications.

  • What are the 4 programming concepts?

There are many programming concepts but the most common ones are variables, control structures, data structures and syntax. They all cut across a wide range of programming Languages.

  • How do you practice programming concepts?

There are different ways to practice programming concepts as beginners which include reading and understanding the syntax of a programming language, writing code to solve problems ranging in size and complexity and practising alongside a tutorial and building projects.

  • What are the 5 basic coding concepts?

The 5 basic coding concepts are variables, algorithms, functions, data structures and control structures. They are important in understanding the information flow and manipulation of data in a computer program. Programmers use their understanding of these concepts to create more efficient and reliable code.

Quiz

  1. The language computers operate on is called _________.

Answer: Machine code

  1. Programmers use programming languages to communicate with the computer. 

True or False.

Answer: True

  1. Control structures are used to control the flow of  ________ in a computer program.
  1. Variables
  2. Functions
  3. Data

Answer: C

  1. Functions are blocks of code that perform a specific task. 

True or False

Answer: True

  1. Data structures are a way of storing and organizing ______ in a program.

Answer: Data 

Leave a Reply

Your email address will not be published. Required fields are marked *

en_USEnglish