Logo 
Search:

C Programming FAQ

Submit Interview FAQ
Home » Interview FAQ » C ProgrammingRSS Feeds

C programming practical question 12

  Shared By: Adah Miller    Date: Jan 24    Category: C Programming    Views: 151

Answer:

main()
{
int c=- -2;
printf("c=%d",c);
}


Answer:
c=2;


Explanation:
Here unary minus (or negation) operator is used twice. Same maths rules applies, ie. minus * minus= plus.
Note:
However you cannot give like --2. Because -- operator can only be applied to variables as a decrement operator (eg., i--). 2 is a constant and not a variable.

Share: 
 

Didn't find what you were looking for? Find more on C programming practical question 12 Or get search suggestion and latest updates.


Your Comment
  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].


Tagged: