Operators
Operators
Operators
Date: 20.09.2023
Variables and arrays
In C programming, variables, and arrays are fundamental concepts used to store and manage data in a program.
<datatype><variable _name>;
Variable: A variable in C is a named memory location used to store a value of a specific data type. It's a way to label and
refer to a particular chunk of memory, making it easier to work with data in your program.
Arrays: Arrays in C are used to store multiple values of the same data type under a single variable name. Each value in an
array is called an element, and the elements are accessed using an index.
• char myString[20]; // Declaration of a character array to hold a string with a maximum of 19 characters
• char greeting[] = "Hello, world!"; // Declaration and initialization of a character array with a string
#include <stdio.h>
int main() {
int num = 10;
char result = (num % 2 == 0) ? "even" : "odd";
printf("The number %d is %s.\n", num, result);
return 0;
}
Logical and Bitwise operator
Logical operators are used to make decisions based on conditions (true or false), while bitwise
operators are used for bit-level operations on integers.
Relational operators
Assignment operator & Increment,Decrement
operator
Increment and decrement operator example
Summary
Operator precedence in c
Operator precedence determines the grouping of terms in an expression. This affects how an expression is
evaluated. Certain operators have higher precedence than others;