WSQ 09- Multipart Data and Files.

My code is: #include <iostream> #include <fstream> #include <string> using namespace std; int main() { string line; int charCount, lineCount; ifstream infile;   infile.open(“file.txt”); charCount=0; lineCount=0;   if (infile.is_open()) { while( getline (infile, line)) { lineCount++; charCount += line.length(); } } cout<<“Number of characters: “<<charCount<<endl; cout<<“Number of lines: “<<lineCount <<endl;   infile.close( );   return… Continúa leyendo WSQ 09- Multipart Data and Files.

Quiz Week 10

#include <iostream> #include <string> using namespace std; int countChars(string userInput, char theChar){ int countChars = 0; for (int i = 0; i < userInput.size(); i++) { if (userInput[i] == theChar) { ++ countChars; } } return countChars; } int main() { string userInput; char theChar=’a’; cout<<“This program will tell you the number of ‘a’ inside… Continúa leyendo Quiz Week 10

WSQ 06- Factorial Calculation.

Today I made this program that calculates the factorial of whatever number you put. I did it with help of https://www.programiz.com/cpp-programming/examples/factorial, and some help from the programs of my other classmates. I found it difficult at the beginning but then really easy.   My code is: #include <iostream> using namespace std; int main () {… Continúa leyendo WSQ 06- Factorial Calculation.