C# Programming - Operators - Discussion

Discussion Forum : Operators - General Questions (Q.No. 1)
1.
Which of the following are the correct ways to increment the value of variable a by 1?
  1. ++a++;
  2. a += 1;
  3. a ++ 1;
  4. a = a +1;
  5. a = +1;
1, 3
2, 4
3, 5
4, 5
None of these
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
20 comments Page 2 of 2.

Santosh said:   1 decade ago
This += is known as short hand operator which same as variable = variable +1; .

Vipin Rathore BIMT said:   1 decade ago
This += is known as short hand operator who same a=a+1 (a+=1 also mean by a=a+1)

Tulasi Reddy said:   1 decade ago
a+=1; //means a=a+1; where a is an variable,if a is an integer type variable having value 10 then output will be 11

a=a+1; //means if a is an integer type variable having value 10 then output will be 11;

So, both are incrementing by 1;

Neearj kumar said:   1 decade ago
This += is known as short hand operator which same as variable = variable +1; .

Vedhu said:   1 decade ago
a+=1 also mean by a=a+1, so both are same.

Anandhajothi.s said:   1 decade ago
In the option 4 a=+ correct or not and why?

Gowrishangar said:   1 decade ago
In the option 4 a= +1 is correct or not & why?

Anushiya said:   1 decade ago
a=a+1 is is correct we can also declare as a+=1

Jatinders said:   1 decade ago
This += is known as short hand operator which same as variable = variable +1; .

Venkat said:   1 decade ago
a += 1 means a=a+1; //so it is correct
a = a+1; //it is also correct


Post your comments here:

Your comments will be displayed after verification.