array program

1
/* Author: Roderick Bennett Class: C++ Programming Online, Fall 2013 Assignment: Chapter 8, Programming Exercise 1 This program creates an array named Alpha of 50 components of type double. The output of the program computes the square of the first 25 indices and Takes 3 times the index of the remaining indices. The output is displayed on the screen with ten numbers per line. */ #include <iostream> using namespace std; const int N = 50; int main() { int alpha[N]; for (int i = 0; i < N; i++) { if (i < 25) { alpha[i] = i*i; } else alpha[i] = 3 * i; } cout << "The contents of the array alpha are: \n\n"; for (int j = 0; j < N; j++) { cout << alpha[j] << " "; if ((j + 1) % 10 == 0) cout << endl; } cout << endl << endl; system("pause"); return 0; }

Upload: roderick-bennett

Post on 26-Sep-2015

217 views

Category:

Documents


1 download

DESCRIPTION

C++ array program for principals of programming. class room assignment

TRANSCRIPT

/*Author: Roderick BennettClass: C++ Programming Online, Fall 2013Assignment: Chapter 8, Programming Exercise 1This program creates an array named Alpha of 50 components of type double.The output of the program computes the square of the first 25 indices andTakes 3 times the index of the remaining indices. The output is displayedon the screen with ten numbers per line.*/

#include

using namespace std;

const int N = 50;

int main()

{int alpha[N];

for (int i = 0; i < N; i++){if (i < 25){alpha[i] = i*i;}elsealpha[i] = 3 * i;}

cout