Open In App
Related Articles

Algorithms Quiz | SP2 Contest 1 | Question 6

Improve Article
Improve
Save Article
Save
Like Article
Like

Predict the output of the below C program:




#include <stdio.h>
  
int main()
{
    int a = - -3;
      
    printf("a=%d", a);
  
    return 0;
}


(A) a=3
(B) a=-3
(C) a=2
(D) None of the above


Answer: (A)

Explanation: Notice the space between the two minus(-) operators. Here unary operation minus(-) is applied twice instead of the pre-decrement operator, we know in maths that minus*minus gives plus. Therefore, – -3 = -(-3) = 3.

Quiz of this Question
Please comment below if you find anything wrong in the above post

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 28 Aug, 2018
Like Article
Save Article
Previous
Next
Similar Reads