Warning: The magic method Slickr_Flickr_Plugin::__wakeup() must have public visibility in /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php on line 152

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101winter2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101winter2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101winter2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101winter2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101winter2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101winter2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101winter2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101winter2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101winter2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831
{"id":12234,"date":"2015-04-29T17:21:32","date_gmt":"2015-04-29T22:21:32","guid":{"rendered":"https:\/\/carlosgreenprograms.withknown.com\/2015\/quiz-11"},"modified":"2015-04-29T17:21:32","modified_gmt":"2015-04-29T22:21:32","slug":"quiz-11-14","status":"publish","type":"post","link":"https:\/\/kenscourses.com\/tc101winter2015\/2015\/quiz-11-14\/","title":{"rendered":"QUIZ #11"},"content":{"rendered":"
\n

#TC1017<\/a> #QUIZ11<\/a><\/p>\n

Here is the gitbub link to both exercises: https:\/<\/wbr>\/<\/wbr>github.com\/<\/wbr>carlosgreen\/<\/wbr>TC1017\/<\/wbr>blob\/<\/wbr>master\/<\/wbr>bananas.cpp<\/a> and https:\/<\/wbr>\/<\/wbr>github.com\/<\/wbr>carlosgreen\/<\/wbr>TC1017\/<\/wbr>blob\/<\/wbr>master\/<\/wbr>readnumbers.cpp<\/a><\/p>\n

When using external files, you can open them with a program and read them line by line in order to receive information relevant for your program.<\/p>\n

In this case, the first code will read a series of numbers that were placed line by line and then add those numbers.<\/p>\n

In order to do that, we will need to open the file, and create a vector to store all the values in each line.<\/p>\n

Also, we will need to transform string characters (the numbers from the file) into integers and for that we will use the function (atoi). <\/p>\n

Here is an example of how the code should look:<\/p>\n

#include<\/a> <iostream><\/p>\n

#include<\/a> <fstream><\/p>\n

#include<\/a> <sstream><\/p>\n

#include<\/a> <cstdlib><\/p>\n

#include<\/a> <string><\/p>\n

#include<\/a> <vector><\/p>\n

#include<\/a> <cmath><\/p>\n

using namespace std;<\/p>\n

 <\/p>\n

int ReadNumbersFromFiles (string filename){<\/p>\n

 <\/p>\n

  int number_of_lines = 0;<\/p>\n

  int sum = 0;<\/p>\n

  int x;<\/p>\n

  float deb;<\/p>\n

  int mean;<\/p>\n

  float sdev;<\/p>\n

  float var;<\/p>\n

  vector <int> numbers;<\/p>\n

  ifstream myFile;<\/p>\n

  myFile.open(filename.c_str());<\/p>\n

  string line;<\/p>\n

  int numLines = 0;<\/p>\n

 <\/p>\n

while ( getline(myFile, line) ){<\/p>\n

  ++numLines;<\/p>\n

  x = atoi(line.c_str());<\/p>\n

  sum = sum + x;<\/p>\n

  numbers.push_back(x);<\/p>\n

}<\/p>\n

      mean= sum\/ numLines;<\/p>\n

      for(int i = 1; i <= numLines; i++){<\/p>\n

              deb = (x – mean)*(x – mean);<\/p>\n

              sdev = sdev + deb;<\/p>\n

          }<\/p>\n

      var = sdev \/ (numLines – 1);<\/p>\n

      deb= sqrt(var);<\/p>\n

      cout << “Number of lines in text file: ” << numLines<<endl;<\/p>\n

      myFile.close();<\/p>\n

      cout<<“the sum of the numbers: “<< sum<<endl;<\/p>\n

      cout<<“mean: “<<mean<<endl;<\/p>\n

      cout<<“The standard deviation: “<<deb;<\/p>\n

    }<\/p>\n

 <\/p>\n

int main(){<\/p>\n

  string file;<\/p>\n

\/\/  cout<<“please enter the name of the file you wish to open: “<<endl;<\/p>\n

\/\/  cin>>file;<\/p>\n

  ReadNumbersFromFiles(“numbers.txt”);<\/p>\n

}<\/p>\n

\"\"<\/p>\n

Bananas:<\/p>\n

The program needs to find a word from a text file and then print out where it find it no matter the way the word (STRING) is arranged:<\/p>\n

#include<\/a> <iostream><\/p>\n

#include<\/a> <iostream><\/p>\n

#include<\/a> <fstream><\/p>\n

#include<\/a> <sstream><\/p>\n

#include<\/a> <cstdlib><\/p>\n

#include<\/a> <string><\/p>\n

 using namespace std;<\/p>\n

 <\/p>\n

 int bananas(string banana){<\/p>\n

   string str2=”banana”;<\/p>\n

   ifstream myFile;<\/p>\n

   myFile.open(banana.c_str());<\/p>\n

   string line;<\/p>\n

   size_t found;<\/p>\n

    while ( getline(myFile, line) ){<\/p>\n

     found = line.find(str2);<\/p>\n

        if (found!=string::npos)<\/p>\n

            cout << “first ‘banana’ found at: ” <<found<<endl;<\/p>\n

            found=line.find(“banana”,found+1);<\/p>\n

          if (found!=string::npos)<\/p>\n

            cout << “second ‘banana’ found at: ” << found <<endl;<\/p>\n

 <\/p>\n

            found=line.find(“banana”,found+2);<\/p>\n

          if (found!=string::npos)<\/p>\n

            cout << “third ‘banana’ found at: ” << found <<endl;<\/p>\n

 <\/p>\n

            found=line.find(“banana”,found+4);<\/p>\n

          if (found!=string::npos)<\/p>\n

            cout << “forth ‘banana’ found at: ” << found <<endl;<\/p>\n

 <\/p>\n

            found=line.find(“banana”,found+5);<\/p>\n

          if (found!=string::npos)<\/p>\n

            cout << “fifth ‘banana’ found at: ” << found <<endl;<\/p>\n

    }<\/p>\n

 <\/p>\n

    myFile.close();<\/p>\n

 <\/p>\n

  return 0;<\/p>\n

}<\/p>\n

int main(){<\/p>\n

  bananas(“bananas.txt”);<\/p>\n

}<\/p>\n

\"\"<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"

#TC1017 #QUIZ11Here is the gitbub link to both exercises: https:\/\/github.com\/carlosgreen\/TC1017\/blob\/master\/bananas.cpp and https:\/\/github.com\/carlosgreen\/TC1017\/blob\/master\/readnumbers.cppWhen using external files, you can open them… Continue reading →<\/span><\/a><\/p>\n","protected":false},"author":43,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,3,26],"tags":[95,40,456],"_links":{"self":[{"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/posts\/12234"}],"collection":[{"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/users\/43"}],"replies":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/comments?post=12234"}],"version-history":[{"count":6,"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/posts\/12234\/revisions"}],"predecessor-version":[{"id":19564,"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/posts\/12234\/revisions\/19564"}],"wp:attachment":[{"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/media?parent=12234"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/categories?post=12234"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101winter2015\/wp-json\/wp\/v2\/tags?post=12234"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}