Write a C++ program that reads three numbers from the keyboard, calculates the squares of each of those numbers and outputs the result to a file called squares.txt.
What would this look like in c++ code?
#include %26lt;fstream%26gt;
using namespace std;
int main() {
int a, b, c;
cin %26gt;%26gt; a %26gt;%26gt; b %26gt;%26gt; c;
a = a * a; b = b * b; c = c * c;
ofstream outfile ("squares.txt");
outfile.write (a);
outfile.write (' ');
outfile.write (b);
outfile.write (' ');
outfile.write (c);
outfile.close();
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment