Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 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;
}

You might also like