0 votes 0 votes Object Oriented Programming non-gate object-oriented-programming + – Çșȇ ʛấẗẻ asked Aug 28, 2023 • recategorized Nov 4, 2023 by Hira Thakur Çșȇ ʛấẗẻ 446 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes The code will give compiler error because variable rem is not declared. Therefore answer is option A) code won’t compile. dipanshu20 answered Aug 28, 2023 dipanshu20 comment Share Follow See all 2 Comments See all 2 2 Comments reply rexritz commented Aug 28, 2023 reply Follow Share If you observe more carefully there is a comma after declaring num = 5 and not semicolon, so rem is declared as an int. You may be confused because rem is on new line, but the variable declaration code is same as: int num = 5, rem = num % 3; So, the code will compile successfully and output would be option D i.e “Remainder is two”. 0 votes 0 votes dipanshu20 commented Aug 30, 2023 reply Follow Share My mistake option D) remainder is two will be the correct option. I missed the comma written over there. 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes The Ans is (b) The first ternary: (1 ? cout << "remainder is one" : rem == 2 ? cout << "remainder is two" : cout << "divisible by three"); Since 1 is a non-zero value, the condition is considered true, so the first expression is executed: cout << "remainder is one". Shivam_02 answered Aug 28, 2023 Shivam_02 comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes Two errors: 1. Compilation error (not declared rem data type) 2. Syntax error ( ; not given after num = 5) AmartyaRA answered Nov 2, 2023 AmartyaRA comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes Option D is the correct answer. There’s no syntax error in the code, it will calculate rem as 2, and provider output ‘remainder is two’ ninjavin2001 answered Nov 2, 2023 ninjavin2001 comment Share Follow See all 0 reply Please log in or register to add a comment.