home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C Programming Starter Kit 2.0
/
SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso
/
tybc4
/
for5.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1993-03-22
|
458b
|
20 lines
// Program calculates a sum of odd integers in
// the range of 11 to 121
#include <iostream.h>
const int FIRST = 11;
const int LAST = 121;
main()
{
double sum = 0;
for (int i = FIRST; i <= LAST; i += 2)
sum += (double)i;
cout << "Sum of odd integers from "
<< FIRST << " to " << LAST << " = "
<< sum << "\n";
return 0;
}