Sail E0 Webinar
Question


What will be output of this program?


1.
#include
2.
using namespace std;
3.
int main()
4.
{
5.
int i = 3;
6.
int l = i / -2;
7.
int k = i % -2;
8.
cout
Options:
A .  compile time error
B .  -1 1
C .  1 -1
D .  implementation defined
Answer: Option B

Sign of result of mod operation on negative numbers is sign of the dividend.



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers