aliensbrain
  • Home
  • Study
  • Quizzes
  • 🎤AI Practicefree
  • Notebooks
  • Community
  • Sign in
  • C++ Based Questions
  • If p and q are int type variables, what will be the resul...
Multiple choice

If p and q are int type variables, what will be the result of the following expression? p % q Where p = - 16 and q = - 3

  1. 1

  2. -1

  3. 5

  4. -5

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

In C++, the result of the modulo operator (%) with negative numbers follows the sign of the dividend. -16 % -3 results in -1 because -16 = (-3 * 5) + (-1).

Keep practicing — related questions

  • What will be the result of the expression a % b when a and b are of type int and their values are a = -17 a...
  • If m = -16 and n = -5 (m and n are int types), the result of the expression m%n is
  • What will be the result of the expression a % b when a and b are of type int and their values are a = 10 an...
  • Suppose p, q, r are integer variables with value 10, 20, 30 respectively. What will be the value of the fol...
  • Suppose a, b and c are integer variables assigned values 8, 3 and -5 respectively. In this case, the respec...
  • Suppose i, j and k are integer variables with values 1, 2, 3 respectively, what is the value of the followi...
  • Which of these variables are of type int?
  • What is the output of the following expression? int a=16,b= -8; cout<
Play the full quiz 🎤 Practise this topic out loud
Advertisement
© Aliensbrain | all rights reserved
  • About
  • Contact
  • Terms and Condition
  • Privacy Policy