• Breaking News

    Tuesday 10 January 2017

    C++ arithmetic & decrement operator

    Write a program that generates the following output:

       10

       20

       30

     Use an integer constant for the 10, an arithmetic assignment operator to generate the 20, and a decrement operator to generate 19.


    CODE:
    #include <iostream>
    /*  Author: Danial Ahmed
        Website: http://program-cpp.blogspot.com/
        Contact: danyalphc@gmail.com */
    using namespace std;
    int main(){
        int kons=10;
        int r1=2*kons, r2=r1-1;
        cout << kons << endl << r1 << endl << r2 << endl;
        return 0;
    }

    OUTPUT:

    No comments:

    Post a Comment