ipv6 ready
JAR
cover

Getting to Know the Basics of Programming for Beginners

Write: Jeffry Azhari RosmanDate: 01 December 2024 17:55

What is Programming?

Programming is the process of writing instructions that a computer can understand to perform a specific task. With programming, we can create applications, websites, systems, and various other software that are useful for everyday life.

Why Should You Learn Programming?

  • Opening career opportunities in various technology fields.
  • Improve problem solving and logic skills.
  • Supporting innovation and creativity through technology.
  • Mastering much-needed future skills.

Programming Basics

1. Variables

Variables are used to store data that can be accessed and manipulated while the program is running.

Sample.js

// Declare variables
let name = "Ali"; // String type variables
let old= 25; // Number type variables
let isStudent = true; // Boolean type variables

// Access and manipulate variables
console.log("Name:", name ); // Output: Name: Ali
console.log("Old:", old); // Output: Old: 25
console.log("Student:", isStudent); // Output: college student: true

// Modify variable values
name = "Budi";
age = 26;
isStudent = false;

console.log("New Name:", name); // Output: New Name: Budi
console.log("New Age:", age); // Output: New Age: 26
console.log("Student:", isStudent); // Output: Student: false
            

2. Conditions

Conditions help programs make decisions based on certain logic, such as using if or switch.

Sample.js

let age = 20;

if (age < 18) {
	console.log("You are not old enough to get a driver's license.");
} else if (age >= 18 && age < 21) {
	console.log("You are old enough to get a driver's license.");
} else {
	console.log("You are an adult and can do many things!");
}

let day = "Monday";

switch (day) {
	case "Monday":
    console.log("Today is the start of the work week.");
    break;
case "Friday":
    console.log("Today is the end of the work week.");
    break;
case "Saturday":
case "Sunday":
    console.log("Weekend! Time to relax.");
    break;
default:
	console.log("Regular day.");
}

            

3. Looping

Looping allows a program to repeat a certain process using for or while.

Sample.js

// Using for loop to print numbers from 1 to 5
for (let i = 1; i <= 5; i++) {
 console.log("Number:", i);
}

// Use while loop to print numbers from 1 to 5
let i = 1;

while (i <= 5) {
 console.log("Number:", i);
 i++; // Increment value i
}
            

4. Function

A function is a block of code designed to perform a specific task, so it can be reused in different parts of a program.

Sample.js

// Define a function to display a greeting
function sapa(name) {
	console.log("Hello, " + name + "! Welcome.");
}

// Call the function
sapa("Ali");
sapa("Budi");
            

Programming Learning Tips

  1. Start with an easy programming language, like Python or JavaScript.
  2. Practice consistently to strengthen understanding.
  3. Join the programmer community to share experiences.
  4. Take an online course or tutorial for more focused guidance.

Conclusion

Programming is an essential skill in today's digital age. By understanding the basics of programming, you have begun your journey to create something useful and inspiring the world. Don't be afraid to learn and keep growing!