Skip to content
Snippets Groups Projects
Commit 922a7852 authored by Ross Netusil's avatar Ross Netusil
Browse files

first commit

parent 5cb489fc
No related branches found
No related tags found
No related merge requests found
#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
; }
}
#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;
}
#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
;}
#include <iostream>
#include <stdio.h>
int main()
{
int num=1; // define num
char *cptr; //define a pointer
cptr = (char *)&num; //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;
}
pd.c 0 → 100644
#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 ; }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment