What is stored in ans as a result of the arithmetic expression, given the following declarations?
int ans = 10, v1 = 5, v2 = 7, v3 = 18;
ans += v1 + 10 (v2 / 5) + v3 / v2;
a. 18
b. 32
c. 28
d. 30
e. none of the above
Correct Option : c. 28
Solution :
using System;
namespace Example14
{
class Program
{
static void Main(string[] args)
{
int ans = 10, v1 = 5, v2 = 7, v3 = 18;
ans += v1 + 10 * (v2-- / 5) + v3 / v2;
Console.WriteLine(+ans);
}
}
}
Output : 28