write the c++ code for defining a variable x=3.5 and incrementing it by 2. in matlab

Here's the C++ code to define the variable x as 3.5 and increment it by 2:

#include <iostream>

int main() {
    double x = 3.5;
    x += 2;
    std::cout << "x = " << x << std::endl;
    return 0;
}
125 chars
9 lines

In MATLAB, the equivalent code would be:

main.m
x = 3.5;
x = x + 2;
disp(['x = ' num2str(x)]);
47 chars
4 lines

Note that in MATLAB, the disp function is used to display the result.

gistlibby LogSnag