πŸŽ‰ New: Top 75 PHP Interview Questions for 2026 β€” Free for all learners

Computer Programming – Basic Operators

P
php Guru
Β· November 29, 2025 Β· 3 min read Β· Updated November 29, 2025

πŸ“Œ Key Takeaways

  • Computer Programming – Basic Operators
  • Basic Operators
  • What Are Operators?
  • Types of Operators
  • When Do You Use Operators?
Advertisement

Basic Operators

In every programming language, operators are the symbols used to perform operations on values and variables. Think of operators as tools that help your program calculate results, compare values, or make decisions. Just like arithmetic in real life uses +, –, Γ—, and Γ·, programming languages provide their own sets of operators.

Different languages (C, Java, Python) may have slight variations, but the fundamental concepts remain the same. This chapter introduces the most common operator categories you will use in your programs.


What Are Operators?

Operators tell the computer what action to perform. They work on values called operands.
Example:

10 + 20

Here:

  • 10 and 20 β†’ operands
  • + β†’ operator

Types of Operators

Most programming languages support the following categories of operators:


Arithmetic Operators

These operators perform basic mathematical operations.

OperatorMeaningExample
+Additiona + b
Subtractiona – b
*Multiplicationa * b
/Divisiona / b
%Modulusa % b (remainder)

Assignment Operators

Assignment operators are used to assign values to variables.

OperatorMeaningExample
=Assign valuex = 10
+=Add and assignx += 5 (x = x + 5)
-=Subtract and assignx -= 3
*=Multiply and assignx *= 2
/=Divide and assignx /= 2

Relational (Comparison) Operators

These operators compare two values and return true or false.

OperatorMeaningExample
==Equal toa == b
!=Not equal toa != b
>Greater thana > b
<Less thana < b
>=Greater or equala >= b
<=Less or equala <= b
basic operators, programming operators, arithmetic operators, relational operators, logical operators, assignment operators, C operators, Java operators, Python operators, programming tutorial

Logical Operators

Logical operators help combine conditions.

OperatorMeaningExample
&& (and) / andTrue if both conditions are truea > 5 && b < 10
|| (or) / orTrue if at least one condition is truea == 10 || b == 20
! (not)Reverses condition!false β†’ true

Unary Operators

These operate on a single operand.

OperatorMeaningExample
++Incrementx++
Decrementx–
Unary minus-x

Example in C

#include <stdio.h>

int main() {
    int a = 10, b = 20;
    int result = a + b;

    printf("Result = %d", result);
    return 0;
}

Example in Java

class Main {
    public static void main(String[] args) {
        int a = 10, b = 20;
        int result = a + b;

        System.out.println("Result = " + result);
    }
}

Example in Python

a = 10
b = 20
result = a + b

print("Result =", result)

When Do You Use Operators?

You will use operators when you need to:

  • Perform calculations
  • Compare values
  • Make decisions using conditions
  • Work with loops
  • Update variable values

Operators are used in almost every line of code you write.

FAQ

What are basic operators in programming?

Basic operators are symbols used to perform operations such as addition, comparison, or logical evaluation in a program.

Are operators the same in all programming languages?

Most languages share similar operator concepts, but syntax differences may exist.

What is the difference between = and ==?

= assigns a value, while == compares two values.

What does the modulus operator (%) do?

It returns the remainder of a division operation.

Why are operators important in programming?

They allow programs to perform calculations, make decisions, and control the flow of execution.

P
php Guru
← Previous Post
Computer Programming – Keywords
Next Post β†’
Computer Programming – Decision Statements

Leave a Reply

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

Prove your humanity: 10   +   6   =