answersLogoWhite

0


Best Answer

increment operator increments the variable by 1 at a time and decrement operator decrements by 1 in this we have two types increments pre_increment and post increment.

In pre_increment the original value is incremented by 1 and assign the new value

n=10

i=++n

then i =11

In post increment the original value is assigned and after it increments value by 1.

n=10

i=n++

then i=10

example:

k=5

i=k++ + ++k

i=?

ans:

in first k++ value is 5

second ++k value is 7

i=5+7=12

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

12y ago

C, C#, Java, and C++ using two forms:

post-increment, x++;

pre-increment: ++x;

replace increment with decrement:

x-- and --x

Essentially, they are short hands for

x = x + 1; or

x = x - 1, or

x +=1;

x -= 1;

However, the placement of post- or pre- increment or decrement within an expression matters - the semantic part, not the topic here

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is increment and decrement operators?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Why are increment and decrement used in c?

To increment or decrement a value


What are unary operators in javascript?

Binary operators are the common ones like +, -, /, *, <, >, !=, etc.. These you use with two objects, like : 1 + 2 Unary are the ones that does not need another object, like : ++, +, --, -, ! Like var a = 5; // Not this. this is a assignment a++; //Increment a in one ++a; //Increment a in one a--; // Decrement a in one --a; // Decrement a in one !a; // Logical opposite of a +a; // Positive value of a -a; // Negative value of a


How many operators are there in C Language?

There are several operators in the C programming language, which are used to perform various operations on variables and values. Here is a list of some of the most commonly used operators in C: Arithmetic operators: +, -, *, /, % (addition, subtraction, multiplication, division, modulus) Assignment operators: =, +=, -=, *=, /=, %=, &=, |=, ^=, = Comparison operators: ==, !=, , = (equal to, not equal to, less than, greater than, less than or equal to, greater than or equal to) Logical operators: && (AND), || (OR), ! (NOT) Bitwise operators: &, |, ^ (AND, OR, XOR) Increment and decrement operators: ++ (increment), -- (decrement) Conditional operator: ?: (ternary operator) It's important to note that there may be some additional operators depending on the specific C compiler or implementation being used.


How can you offset a pointer in C?

Increment or decrement the pointer by the required offset.


What are C arithmetic instructions?

C does not have instructions of any kind, it has operators and functions. The arithmetic operators are provided for all built-in numeric types (integer and real numbers, including mixed mode arithmetic). They are as follows: Unary operators: positive (+) e.g., +x negative (-) e.g., -x prefix increment (++) e.g., ++x prefix decrement (--) e.g., --x postfix increment (++) e.g., x++ postfix decrement (--) e.g., x-- Binary operators: add (+) e.g., x + y subtract (-) e.g., x - y multiply (*) e.g., x * y divide (/) e.g., x / y modulo (%) e.g., x % y

Related questions

What is a 'post fix expression' in java programming?

Postfix expressions are expressions where the operator is at the end of the expression. These include the "++" (increment) and "--" (decrement) operators. Most Java expressions use in-fix notation (e.g. "a + b") but the increment and decrement operators can be postfix ("e.g. "a++" to increment variable a) or even prefix (e.g. "++a").


Why are increment and decrement used in c?

To increment or decrement a value


What are unary operators in javascript?

Binary operators are the common ones like +, -, /, *, <, >, !=, etc.. These you use with two objects, like : 1 + 2 Unary are the ones that does not need another object, like : ++, +, --, -, ! Like var a = 5; // Not this. this is a assignment a++; //Increment a in one ++a; //Increment a in one a--; // Decrement a in one --a; // Decrement a in one !a; // Logical opposite of a +a; // Positive value of a -a; // Negative value of a


What are different types of operators?

The different types of operators are as follows: *Arithmatic operator *Relational operator *Logical operator *Assignment operator *Increment/Decrement operator *Conditional operator *Bitwise operator *Special operator


How many operators are there in C Language?

There are several operators in the C programming language, which are used to perform various operations on variables and values. Here is a list of some of the most commonly used operators in C: Arithmetic operators: +, -, *, /, % (addition, subtraction, multiplication, division, modulus) Assignment operators: =, +=, -=, *=, /=, %=, &=, |=, ^=, = Comparison operators: ==, !=, , = (equal to, not equal to, less than, greater than, less than or equal to, greater than or equal to) Logical operators: && (AND), || (OR), ! (NOT) Bitwise operators: &, |, ^ (AND, OR, XOR) Increment and decrement operators: ++ (increment), -- (decrement) Conditional operator: ?: (ternary operator) It's important to note that there may be some additional operators depending on the specific C compiler or implementation being used.


Which arithmatic operations can be performed on pointers?

Increment and decrement only.


What are the different types of operations of c?

c have different types of operations are there these are 1:logical operators 2:conditional 3:arithmetic 4:bit wise operators 5:increment&decrement 6:relational operators 7:assignment operators 8:special operators we can use above operators. we can implementing the operations. suppose logical operators &&,,! by using these we can implement operations


How can you offset a pointer in C?

Increment or decrement the pointer by the required offset.


What are C arithmetic instructions?

C does not have instructions of any kind, it has operators and functions. The arithmetic operators are provided for all built-in numeric types (integer and real numbers, including mixed mode arithmetic). They are as follows: Unary operators: positive (+) e.g., +x negative (-) e.g., -x prefix increment (++) e.g., ++x prefix decrement (--) e.g., --x postfix increment (++) e.g., x++ postfix decrement (--) e.g., x-- Binary operators: add (+) e.g., x + y subtract (-) e.g., x - y multiply (*) e.g., x * y divide (/) e.g., x / y modulo (%) e.g., x % y


What is auto increment and auto decrement mode?

access and update in one instruction.


How do you get your nested loop to decrement and not increment?

Easy. Change any + to -, any += to -=, any ++ to --


What are different type's operators?

The different types of operators are as follows: *Arithmatic operator *Relational operator *Logical operator *Assignment operator *Increment/Decrement operator *Conditional operator *Bitwise operator *Special operator