in Education by

What will be the output of the following C++ function?

  1. int main()
  2.     {
  3.         register int i = 1;
  4.         int *ptr = &i;
  5.         cout << *ptr;
  6. 	return 0;
  7.     }

a) Runtime error may be possible
b) Compiler error may be possible
c) 1
d) 0

1 Answer

0 votes
by

Answer: b
Explanation: Using & on a register variable may be invalid, since the compiler may store the variable in a register, and finding the address of it is illegal.

Related questions

0 votes
    What will be the output of the following C++ code? #include using namespace std; int main () { int cin; cin ... fault b) Nothing is printed c) Error d) cin: garbage value...
asked Oct 19, 2022 by JackTerrance
0 votes
    - What will be the output of the following C code? #include int main() { int i = 97, *p=&i; foo( ... (D) Segmentation fault/code crash Select the correct answer from above options...
asked Dec 24, 2021 in Education by JackTerrance
0 votes
    What will be the output of the following Python function? len(["hello",2, 4, 6]) a) Error b) 6 c) 4 d) 3...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    What will be the output of the following Python function? min(max(False,-3,-4), 2,7) a) -4 b) -3 c) 2 d) False...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    Two vectors M and N are defined as M...
asked Feb 12, 2022 in Education by JackTerrance
0 votes
    What is the output of the following expression? function multi(x,y) { var c = x*y; } multi(20,3); 1. 20 2. 60 3. 3 4. Nothing...
asked Feb 25, 2021 in Technology by JackTerrance
0 votes
    What is the output of the following expression? function multi(x,y) { var c = x*y; } multi(20,3); A) 20 B) 60 C) 3 D) Nothing...
asked Oct 9, 2020 in Technology by JackTerrance
0 votes
    // merge.cpp // merges two containers into a third #include #include //for merge() using namespace std; int src1[] = { 2, 3, 4, ... , src1+5, src2, src2+3, dest); for(int j=0; j...
asked Jun 2, 2022 in Education by JackTerrance
0 votes
    What will be the output of the following Python code? >>>list1 = [1, 3] >>>list2 = list1 >>>list1[0] = 4 >>>print(list2) a) [1, 4] b) [1, 3, 4] c) [4, 3] d) [1, 3]...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    What will be the output of the following Python code? print('*', "abcde".center(6), '*', sep='') a) * abcde * b) *abcde * c) * abcde* d) * abcde *...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    What will be the output of the following Python code? print("abc. DEF".capitalize()) a) Abc. def b) abc. def c) Abc. Def d) ABC. DEF...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    What will be the output of the following Python program? z=set('abc') z.add('san') z.update(set(['p', 'q'] ... ;, ‘c’, [‘p’, ‘q’], ‘san}...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    What will be the output of the following Python program? def foo(x): x[0] = ['def'] x[1] = ['abc'] return id(x) q = ['abc ... (id(q) == foo(q)) a) Error b) None c) False d) True...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    What will be the output of the following Python code? class tester: def __init__(self, id): self.id = str(id) id="224" >>>temp ... >>>print(temp.id) a) 12 b) 224 c) None d) Error...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    What will be the output of the following Python code? print("abc. DEF".capitalize()) a) Abc. def b) abc. def c) Abc. Def d) ABC. DEF...
asked Jan 2, 2023 in Technology by JackTerrance
...