Errors

Report a typo

Our programmer made mistakes in the code again (what a bungler). Find and fix them.

#include <iostream>

int main() {
    int num = 5;
    int &ref = num;

    ref *= 2; // Updating value through reference

    std::cout << "Updated value of num: " << num << std::endl;

    return 0;
}

Sample Input 1:

1

Sample Output 1:

Updated value of num: 2
Write a program in C++
#include <iostream>

int main() {
int num;
std::cin >> num;
int *ref = num;

ref *= 2 // Updating value through reference

std::cout << "Updated value of num: " << *num << std::endl;

return 0;
}

Create a free account to access the full topic