Lec#5
Lec#5
Comments in C language are used to provide information about lines of code. It is widely used for
documenting code. There are two types of comments in the C language.
Single line comments are represented by double slash //. Let's see an example of a single line
comment in C.
1. #include<stdio.h>
2. int main(){
3. //printing information
4. printf("Hello C");
5. return 0;
6. }
Output:
Hello C
Even you can place the comment after the statement. For example:
Multi-Line comments are represented by slash asterisk \* ... *\. It can occupy many lines of code,
but it can't be nested. Syntax:
/*
code
to be commented
*/
1. #include<stdio.h>
2. int main(){
3. /*printing information
4. Multi-Line Comment*/
5. printf("Hello C");
6. return 0;
7. }
Output:Hello C
Operators
Operators are symbols which are used to operate on operands to perform some action.
OR
Operator are word or symbols that cause a program to do something to variables.
The expression is the combination of operand and operator where operand may be constant or
variable.
Basic operators are +, -, *, /.
Types of Operators
The following are the some of the types of operators.
➢ Arithmetic Operator
➢ Relational Operator
➢ Logical Operator
Arithmetic Operator:
An arithmetic operator performs mathematical operations such as addition, subtraction,
multiplication, division etc. on numerical values (constants and variables).
A * B =
* Multiplication (Multiplies both operands.)
200
A relational operator checks the relationship between two operands. If the relation is true, it returns
1; if the relation is false, it returns value 0.
== Equal to 5 == 3 is evaluated to 0
Logical Operators:
An expression containing logical operator returns either 0 or 1 depending upon whether expression
results true or false. Logical operators are commonly used in decision making in C programming.