1. Write C++ statements for the following:
a. Reading 1 line of input and storing the result in the variable myVariable
b. The square root of x - y.
c. The value of 3.62 raised to the 3rd power.
d. The value of 81 raised to the .24 power.
e. Ignoring the first 40 characters or all characters until the character 'B' is found, whichever comes first.
f. Displaying "Hello World" to the screen.
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
int main(int argc, char *argv[])
{
ifstream inData;
ofstream outData;
string variable2;
int myvariable;
int variable;
inData.open("test.dat");
outData.open("testavg.out");
outData << fixed << showpoint;
outData << setprecision(2);
outData << "data" << endl;
inData >> variable2;
outData << "student name: " << variable;
inData.close();
outData.close();
cout << "input variable: ";
cin >> myvariable;
system("PAUSE");
return EXIT_SUCCESS;
}
No comments:
Post a Comment