Education
C Programming

What value is assigned to the type int variable ans in this statement if the value of p is 100 and q is 50?

012

Answer

User Avatar
Wiki User
11/29/2016

It is not possible to answer this question without knowing the actual expression used in the assignment statement. The following are merely example expressions showing some of the values that could be assigned to ans:

int ans, p=100, q=50;

ans = p + q; // ans = 150

ans = p * q; // ans = 5000

ans = p - q; // ans = -50

ans = p / q; // ans = 2

ans = p % q; // ans = 0