1.4.2 for语句

版权声明:本文为博主原创文章,未经博主允许不得转载 https://blog.csdn.net/qit1314/article/details/89925784

书中页数:P11
代码名称:forcount.cc

    #include <iostream>
    
    int main()
    {
        int sum = 0;
    
        // sum values from 1 through 10 inclusive
        for (int val = 1; val <= 10; ++val) 
            sum += val;  // equivalent to sum = sum + val
        std::cout << "Sum of 1 to 10 inclusive is " 
                  << sum << std::endl;
        return 0;
    }

猜你喜欢

转载自blog.csdn.net/qit1314/article/details/89925784
今日推荐