Predict the output of the following program segment: int a=0;
if(a>0)
{ cout<<"Number is positive"; }
else
{ cout<<"Number is negative"; }
a.] Number is positive
b.]Number is negative
c.] No output
d.] Error Message
Answers
Answered by
4
Answer:
I thik the answer is number is negative
Answered by
0
Required Answer:-
Given C∅de Snippet:
int a = 0;
if (a>0) {
cout << "Number is positive";
}
else {
cout << "Number is negative";
}
Language:
- C++
Output:
Number is negative.
Note: 0 is neither negative nor positive but due to some logical errors, the output is - "Number is negative".
Explanation:
- Here, a = 0. So, a > 0 is false as 0 > 0 is false. So, if block will not execute. The else block will execute.
- So, the output is - Number is negative.
Similar questions