@Wo1ves1n0/

Manish(Assignment 3) (Final)

C++

Final step to my project

fork
loading
Files
  • main.cpp
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
Computational Thinking
Assigment 3 template
"Torren Walker"
*/
#include <iostream> //Library
using namespace std; //cout
int main() //main project
{ // Start
  int Result=0, length=0, smallest, largest, MyList[length]; // Integers to declare 
  cout << "How many numbers are you checking for?: "; // text to ask the user to enter the number.
  cin >> length; // Enter the the amount of numbers in the list you would like to add up. 
  for (int i=0; i<length; i++) // For the list
  {
  	cout << "Enter number " << i+1 << ": "; // telling the user to enter the number for each integer within the list. 
  	cin >> MyList[i]; // user enters their desire number for each number within the list
  }
  smallest = MyList[0], largest = MyList[0]; // Set the smallest to 0 along with the largest to 0 
	cout << endl << "Printing Array"<< endl << "--------------" << endl; //text
  for (int i=0; i<length; i++) // For the list
  {
    Result+=MyList[i]; // the result of 0 add the list together. 
  	cout << MyList[i] << endl; //text of the list that is listed for the user to see.
  }
  cout << "--------------" << endl << "Adding your list of numbers" << endl << "--------------" << endl << "Total: " << Result << endl <<"--------------"<< endl; // text to make it easier for the user to understand what is happening. 
    for (int i=0; i < length; i++) // for the list
	{ 
		if (MyList[i] > largest) //defining the largest in the list
		{
			largest = MyList[i]; // declearing the largest in the list
		}
		if (MyList[i] < smallest) //defining the smallest in the list
		{
			smallest = MyList[i]; // declearing the smallest in the list
		}
	} 
	cout << "Largest integer: " << largest << endl << "--------------" << endl <<	"smallest integer: " << smallest << endl << "--------------" << endl; // Displays the text of showing the largest and smallest number within the list.
	return 0;
} //End