Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 52.15.37.74
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/grpatillo/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/grpatillo/array1.cpp
// show the using an array

#include <iostream>

using namespace std;

int main()
{
	// del.
	const int MAX = 50;		
	float myArr[MAX];

	// float myArr[50];---------------another method
	
	// Q: first element as 50.3
	
	myArr[0] = 50.3;
	
	// Q: The rests 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: out the 10th, 20th, 30th, 40th?
	cout << myArr[9] << "\t " << myArr[19] << "\t " << 
		myArr[29] << "\t " << myArr[39] << endl;

	// OutPut:      77.7	77.7	77.7	71.7

	// Q: output ALL?
	for(int i=0; i<=MAX-1; i++)
		cout << myArr[i] <<  endl;

	// Q: Make all 0s?
	for(int i=0; i<=MAX-1; i++)
		myArr[i] = 0;


	cout << "\n\nWorks!!!\n\n";
	return 0;
}

Stv3n404 - 2023