Skip to content

Instantly share code, notes, and snippets.

#include "summation.h"
#include <iostream>
using namespace std;
double sum(double array[], int size); // Function prototype
int main()
{
const int SIZE = 6;
#ifndef SUMMATION_HPP
#define SUMMATION_HPP
double sum(double array[], int size);
#endif
#include "summation.h"
double sum(double arr[], int size)
{
double total = 0.0; // accumulator
for(i = 0; i < size, i++)
total += array[i];
return total;
}
#include "Patron.hpp"
#include <string>
Patron::Patron(std::string idn, std::string n) // constructor that takes a Patron idNum and name
{
idNum = idn;
name = n;
}
std::string Patron::getIdNum() // get and return the Patron's idNum
#include "Book.hpp"
#include <string>
Book::Book(std::string idc, std::string t, std::string a) // takes an idCode, title and author;
{ // checkedOutBy and requestedBy should be
idCode = idc; // initialized to NULL; a new Book should be
title = t; // on the shelf
author = a;
setLocation(ON_SHELF);
setCheckedOutBy(0);
bool stringIsInt(string string)
for (int i = 0; i < string.length(); i++)
{
if(string.at(i) == "+" || string.at(i) == "-" || string.at(i) = " ")
{
for(int j=i; j<string.length(); j++)
{
if(isspace(string.at(j)))
valid = true;
bool stringIsInt(string string)
{
bool valid = true;
for (int i = 0; i < string.length(); i++)
{
if(string.at(i) == "+" || string.at(i) == "-" || string.at(i) = " ")
{
for(int j=i; j<string.length(); j++)
{
bool stringIsInt(string string)
for (int i = 0; i < string.length(); i++)
{
if(string.at(i) == "+" || string.at(i) == "-" || string.at(i) = " ")
{
for(int j=i; j<string.length(); j++)
{
if(isspace(string.at(j)))
valid = true;
void findMode(int array[], int size); // Function Prototype
int main () {
const int SIZE = 10;
int array[SIZE] = {1, 2, 2, 2, 3, 4, 4, 5, 5, 6};
findMode(array, SIZE);
return 0;
}
void findMode(int array[], int size); // Function Prototype
int main () {
const int SIZE = 10;
int array[SIZE] = {1, 2, 2, 2, 3, 4, 4, 5, 5, 6};
findMode(array, SIZE);
return 0;
}