Computer Science, asked by Anju9616, 1 year ago

What is increment and decrement operator 2 computer?

Answers

Answered by rishirajsharma197
5

Increment and decrement operators are unary operators that add or subtract one, to or from their operand, respectively. They are commonly implemented in imperative programming languages. C-like languages feature two versions (pre- and post-) of each operator with slightly different semantics.

Answered by CARELESSGIRL
6

ɪɴᴄʀᴇᴍᴇɴᴛ ᴀɴᴅ ᴅᴇᴄʀᴇᴍᴇɴᴛ ᴏᴘᴇʀᴀᴛᴏʀ ᴄᴏᴍᴘᴜᴛᴇʀ

simple way to lear i++,i— is that consider a simple example…..

Increment operators are used to increase the value of the variable by one and decrement operators are used to decrease the value of the variable by one in C programs.

Syntax:

▶Increment operator: ++var_name; (or) var_name++;

▶Decrement operator: – -var_name; (or) var_name – -;

Example:

Increment operator : ++ i ; i ++ ;

Decrement operator : – – i ; i – – ;

EXAMPLE PROGRAM FOR INCREMENT OPERATORS IN C:

In this program, value of “i” is incremented one by one from 1 up to 9 using “i++” operator and output is displayed as “1 2 3 4 5 6 7 8 9”.

C

1

2

3

4

5

6

7

8

9

10

11

12

//Example for increment operators

#include <stdio.h>

int main()

{

int i=1;

while(i<10)

{

printf("%d ",i);

i++;

}

}

ʙᴇ ʜᴀᴘᴘʏ ✿◕ ‿ ◕✿

Similar questions