Programming and Graphics

(Kiana) #1

C C++/Matlab/Fortran 77Dictionary 333


Fortran 77 C++

#include<iostream>

read (5,*) a cin>>a;
read (5,*) a,b,c cin>>a>>b>>c;
write (6,*) a,b,c cout<<a<<b<<c<<endl;
write (6,*) cout<<“\n”;
write (6,*) ”Please enter a:” cout<<“Please enter a:\n”;
write (6,*) ”temp=”, tmp cout<<“temp=”<<tmp<<“\n”;

#include<iostream>
write (6,100) a #include<iomanip>
100 Format (f10.5) cout<<setprecision(5)<<setw(10);
cout<<a;

#include<fstream>
open (1, file=”input.dat”) ifstream devname;
devname.open(“input.dat”);

#include<fstream>
open (1, file=”input.dat”) ifstream devname(“input.dat”);
read (1,*) a,b,c devname>>a>>b>>c;
read (1,*) a(i,j) devname>>a[i][j];
close (1) devname.close(“input.dat”);

#include<fstream>
open (2, file=”output.dat”) ofstream othername;
othername.open(“output.dat”);

#include<fstream>
open (2, file=”output.dat”) ofstream othername(“output.dat”);
write (2,*) a,b,c othername<<a<<b<<c<<endl;
write (2,*) a(i,j) othername<<a[i][j]<<endl;
close (2) othername.close(“output.dat”);

Table C.6 Fortran 77/C++ equivalent structures and calls regarding input
and output (I/O). The#includestatements are placed at the top of the
file containing the C++ code. iostream contains the header files of
the standard input/output (keyboard/monitor) stream. fstreamcontains
the header files of thefilestream.

Free download pdf