Name: ____________________________________________________ Alpha: _____________________
Describe help received: _________________________________________________________________
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
string* getWords(string filename, int k);
int main() {
string* A = getWords("tmp.txt",10);
for( int i = 0; i <= 10; i++ ) {
if( "a" <= A[i][0] && A[i][0] <= "z" )
A[i][0] -= 32;
}
for( int i = 0; i <= 10; i++ )
cout << A[i] << endl;
return 0;
}
string* getWords(string filename, int k) {
ifstream fin(filename);
string* W = new string*[k];
while(--k >= 0 && fin >> W[k]);
return W;
}
Turn in a screenshot showing your program running, and a codeprint printout of your code.
#include <iostream>
using namespace std;
double pow(double, int);
int main() {
double x;
int n;
cout << "Enter x: ";
cin >> x;
cout << "Enter n: ";
cin >> n;
double xn = pow(x,n);
cout << "x^n is " << xn << endl;
return 0;
}
double pow(double x, int n) {
double product = 1;
for( int i = 0; i < n; i++ )
product *= x;
return product;
}
Turn in a screenshot showing your program running, and a codeprint printout of your code.