ccplusplus.com
Learn C, C++ Concepts
Sunday, February 5, 2012
modulus operator example c++
/************************************************************************* * File : modulus-operator.cpp * Author : Saurabh Gupta * Desc : modulus operator example c++ * Source : http://www.ccplusplus.com/p/c_15.html * Created : 8:59 PM Sunday, February 05, 2012 *************************************************************************/ #include
using namespace std; int main() { /* * nCount holds the current number to print */ int nCount = 1; // start at 1 /* * Loop continually until we pass number 100 */ while (nCount <= 100) { cout << nCount << " "; // print the current number // if nCount is divisible by 20, print a new line if (nCount % 20 == 0) cout << endl; nCount = nCount + 1; // go to next number } // end of while return 0; } /* * OUTPUT * [sgupta@rhel6x86 cpp]$ c++ modulus-operator.cpp -o modulus-operator [sgupta@rhel6x86 cpp]$ ./modulus-operator 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 [sgupta@rhel6x86 cpp]$ */
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment