can someone help me with this please, the code should be in C++. This is what I
ID: 3832528 • Letter: C
Question
can someone help me with this please, the code should be in C++.
This is what I did so far...
#include <iostream>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <ios>
using namespace std;
void PrintTextFile(string name){
ifstream myInputFile;
string line;
bool lastReadGood = true;
myInputFile.open(name.c_str());
while(true){
getline(myInputFile, line);
lastReadGood = myInputFile.good();
if (lastReadGood == false){
break;
}
cout << line << endl;
}
myInputFile.close();
return;
}
int main(){
string inFile;
ifstream triangle;
bool lastReadGood = true;
triangle.open(name.c_str());
while(true){
getline(triangle, inFile);
lastReadGood = triangle.good();
if(lastReadGood==false){
break;
}
cout << inFile<< endl;
}
triangle.close();
double a, b, c, s;
cin >> inFile;
s = (a + b + c) / 2;
cout << fixed << setprecision(2) << s << endl;
return 0;
}
Explanation / Answer
#include #include long fact(int); void main() { clrscr(); int i, n, c; coutn; for(i=0; iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.