// Unit 9 modularized.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<iostream>
#include<string>
usingnamespace std;
// Declare functions.
int askStudents();
int askMovies(int getStudents);
//Declare variables.
int getStudents;
int main()
{
getStudents = askStudents();
return 0;
}
int askStudents()
{
cout << "How many students were surveyed? ";
cin >> getStudents;
while (getStudents < 0)
{
cout << "Please enter a non-negative number: ";
cin >> getStudents;
}
return getStudents;
}
int askMovies(int getStudents)
{
// Creating array "setMovies" with size of getStudents using pointer.
int *setMovies;
setMovies = newint[getStudents];
// Storing the amount of movies each student watched into setMovies array.
for (int i = 0; i < getStudents; i++)
{
cout << "How many movies did each student watch: ";
cin >> setMovies[i];
}
return setMovies;
}