Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

Assignment Operators

#include <iostream>
using namespace std;

int main() {
    int a, b;

    // 2 is assigned to a
    a = 2;

    // 7 is assigned to b
    b = 7;

    cout << "a = " << a << endl;
    cout << "b = " << b << endl;
    cout << "
After a += b;" << endl;

    // assigning the sum of a and b to a
    a += b;  // a = a +b
    cout << "a = " << a << endl;

    return 0;
}
Source by www.programiz.com #
 
PREVIOUS NEXT
Tagged: #Assignment #Operators
ADD COMMENT
Topic
Name
2+6 =