diff --git a/Analyze.c b/Analyze.c new file mode 100644 index 0000000000000000000000000000000000000000..c933efa0d2eea872c4f80d9509c65384b2788274 --- /dev/null +++ b/Analyze.c @@ -0,0 +1,42 @@ +#include <iostream> +#include <string> +#include <fstream> + +int main(int argc, char **argv) +{ + if (argc == 1) //No filename was entered. + { + std::cout << "No_Filename_Given._Exiting." << std::endl; + return 1; + } + if (argc > 2) //Too many arguments given. + { + std::cout << "More_than_one_filename_given._Exiting." << std::endl; + return 1; + } + std::ifstream infile(argv[1]); + if (infile) + { + + {float a,Min=1000000,Max=0,Sum=0,Mean,Entries=0; //Define as float a, Min, Max, Sum, Mean, Entries, and set initial values for Min, Max, Sum, Entries. + while (infile >> a) //Set a == value on the next line in file. + { + if ( a < Min ) Min = a; //Set Min to smaller of previous value or a. + if (a > Max ) Max = a; //Set Max to Larger of previous value or a. + Entries = Entries++; //Increase entry count by one. + Sum = Sum + a; //Add current a value to running Sum. + Mean = Sum/Entries;} + std::cout << "Entries: " << Entries << "_;"; + std::cout << "Max: " << Max << "_;"; + std::cout << "Min: " << Min << "_;"; + std::cout << "Sum: " << Sum << "_;"; + std::cout << "Mean: " << Mean << "." << std::endl; // Report Values + + return 0 + ;}} + else + { + std::cout << "Can_not_Open_File. " << argv[1] << std::endl; //Unable to open file. + return 1 + ; } +} diff --git a/CacheSize8.cpp b/CacheSize8.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f95cec2c84ae33f541ba08b37b263738b8284b7e --- /dev/null +++ b/CacheSize8.cpp @@ -0,0 +1,28 @@ +#include <iostream> +#include <stdio.h> +#include "TStopwatch.h" + +int main() +{ + + int i; + int a; + float sum = 0; // define i,a,sum + a=1000; // set a=1000 + + int array [a]; //define array + for (i=0; i< a; i++) + { + array[i]=i; + } + TStopwatch mystopwatch = TStopwatch (); + for (i=0; i<a; i++) + { + + sum = sum + array[i]; + } // populate array with integers up to n=1, take running summation + + Double_t time = mystopwatch.RealTime(); + std::cout << time << ".\n" ; // output sum + return 0; +} diff --git a/Summation_3.c b/Summation_3.c new file mode 100644 index 0000000000000000000000000000000000000000..885bd0701ac99b28475073ec6a49e7532bb2d9c3 --- /dev/null +++ b/Summation_3.c @@ -0,0 +1,15 @@ +#include <iostream> + +int main() +{ + int i; + std::cout << "Please enter an integer value: "; //solicit user input + std::cin >> i; + float b; + b=(i*(i+1)/2); // output summation + +std::cout << "The Value you entered is " << i; +std::cout << " and the sum of all whole numbers up to and including your value is " << b << ".\n"; // report to user +return 0 +;} + diff --git a/endianness.c b/endianness.c new file mode 100644 index 0000000000000000000000000000000000000000..a62d46ceabdb3c5766de8aa701c7965cf4606cd1 --- /dev/null +++ b/endianness.c @@ -0,0 +1,17 @@ +#include <iostream> +#include <stdio.h> + +int main() +{ +int num=1; // define num +char *cptr; //define a pointer + +cptr = (char *)# //points to last byte of num + +if (*cptr) // if the first byte stores the 1 +printf ("little endian\n"); // respond with LE +else +printf ("big endian\n"); // respond with BE + +return 0; +} diff --git a/pd.c b/pd.c new file mode 100644 index 0000000000000000000000000000000000000000..557260d5e6a717d672dfd3451f7e3289e930ce4e --- /dev/null +++ b/pd.c @@ -0,0 +1,6 @@ +#include <iostream> +#include <limits> // To access std::numeric_limits +int main () +{ +std::cout << std::numeric_limits<double>::digits10 << std::endl; // Reports maximum number of digits in <double> +return 0 ; }