Skip to main content

Define operator, data type, constant, variable

Short answer

An operator is a symbol that performs an operation on operands (e.g., +, =). A data type defines the kind and size of data a variable can store (int, float, char). A constant is a fixed value that cannot change; a variable is a named memory location whose value can vary and must be declared with a type.

What is an operator, datatype, constant and variable? Define.

  • Operator: a symbol that performs an operation on operands, such as +, *, >, &&. Example: in c = a + b, + and = are operators.
  • Data type: it defines the kind of data a variable can store, its size in memory and the operations allowed. Basic types: int (whole numbers), float/double (real numbers), char (a character).
  • Constant: a fixed value that cannot change during program execution, such as 10, 3.14, 'A', "Nepal". A named constant is created using const or #define PI 3.14159.
  • Variable: a named memory location whose value can change while the program runs. It must be declared with a data type before use, for example int count = 0;.

Example:

#include <stdio.h>
#define PI 3.14159
int main(void)
{
    const int DAYS = 7;       /* constant */
    int count = 0;            /* variable */
    float radius = 2.0f;
    count = count + DAYS;
    printf("%d %.2f\n", count, PI * radius * radius);
    return 0;
}

Here DAYS and PI are constants, count and radius are variables, int and float are data types, and =, +, * are operators.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Computer Programming chapter 3 questions →