Re: small program that generates terms in OEIS sequence A016278

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 22 Apr 2008 05:00:20 -0700 (PDT), Antonio Olivares wrote:

> Dear all,
> 
> I wrote a small program prog1.cpp that cranks out the numbers in the sequence A016278 in OEIS
> 
> http://www.research.att.com/~njas/sequences/A016278
> 
> The program runs on slax, but fails to do so on rawhide.
> 
> [olivares@localhost Documents]$ cat prog1.cpp 
> #include <iostream.h>
> #include <stdlib.h>
> #include <math.h>
> 
> int main(int argc, char *argv[])
> {
>   int i; 
>   double j;
>   for (i=1; i < 16; i++)
>   {
>     j =
> (4.0/7.0)*pow(2.0,i-1)+(-3.0/2.0)*pow(3.0,i-1)+(27.0/14.0)*pow(9.0,i-1);
>             cout << i << ' ' << j << "\n";
>   }
>   return EXIT_SUCCESS;
> }
> 
> [olivares@localhost Documents]$ cat /etc/fedora-release 
> Fedora release 8.93 (Rawhide)
> [olivares@localhost Documents]$ c++ -o prog1 prog1.cpp 
> prog1.cpp:1:22: error: iostream.h: No such file or directory
> prog1.cpp: In function ‘int main(int, char**)’:
> prog1.cpp:13: error: ‘cout’ was not declared in this scope
> [olivares@localhost Documents]$ 

> Is there something that needs to be done so that the program can compile fine in rawhide?
> 

Make it C++. Include <iostream>, <cstdlib>, <cmath>. Consider the
namespaces, e.g. cout is std::cout in global scope. Use ios::endl not
'\n'. Declare i inside the for-statement. Declare j inside the for-loop
body. Then it comes closer to C++.

-- 
fedora-test-list mailing list
fedora-test-list@xxxxxxxxxx
To unsubscribe: 
https://www.redhat.com/mailman/listinfo/fedora-test-list

[Index of Archives]     [Fedora Desktop]     [Fedora SELinux]     [Photo Sharing]     [Yosemite Forum]     [KDE Users]

  Powered by Linux