Operator, Header File

Filter Course


Operator, Header File

Published by: Zaya

Published date: 17 Jun 2021

Operator, Header File

Operators, Header File

A header file is a file containing C declarations and macro definitions (see Macros) to be shared between several source files. You request the use of a header file in your program by including it, with the C preprocessing directive ‘ #include ‘. Header files serve two purposes.

Your request to use a header file in your program by including it with the C preprocessing directive #include, like you have seen the inclusion of stdio.h header file, which comes along with your compiler.

Including a header file is equal to copying the content of the header file but we do not do it because it will be error-prone and it is not a good idea to copy the content of a header file in the source files, especially if we have multiple source files in a program.

A simple practice in C or C++ programs is that we keep all the constants, macros, system-wide global variables, and function prototypes in the header files and include that header file wherever it is required.

Operators are symbols that tell to program-specific mathematical or logical operations. Operators are used to operating the operand. Programming languages typically support a set of operators. There are different types of operators in the C programming language.

  • Arithmetic operator
  • Relational operator
  • Assignment operator
  • Logical operator
  • Unary operator
  • Comma operator
  • Ternary operator

Arithmetic operator
The arithmetic operator is used to perform the mathematical calculation. C contains five arithmetic operators.
Example:

Operators Meaning Example
+ Addition a+b
Subtraction a-b
* Multiplication a*b
/ Division a/b
% Modules a%b

Relational operator
The relational operator determines the relationship between two different operands. It is also known as a comparison operator, which can be used to check the condition. It always returns a true or false result.
Example:

Operators Meaning Example
< Less than a
<= Less than or equal a<=b

>

 

Greater than a>b
>= Greater than or equal a>=b
== Equal to a==b
!= Not equal to a!=b

Assignment operator
An assignment operator assigns the value of an expression to an identifier.
Example:

Operators Meaning Example
= assign A=5+6

Logical operator
Logical operators are used to calculating logical expressions. It accepts two or more inputs and produces a single output.
Example:

Operators Meaning Example
$$ Logical AND (a>b)$$(a>c)
|| Logical OR (a>b)||(a>c)
! Logical NOT a!=b

Comma operator
C allows us to put multiple expressions in the same statement separated by a comma.
Example: a,b;

Ternary operators
An expression that makes use of the conditional operator is called a ternary operator.
Example: (a>b)? true:false

Input-Output Statement
An input/output statement or IO statement is a portion of a program that instructs a computer on how to read and process information. It pertains to gather information from an input device or sending information to an output device. Input, Output, Programming terms.