1. Write a program that will illustrate the use of a function for computing the square of a number. There must be three other functions aside from main(). The first function must be responsible for inputting the data, the second for computation of squares and the third, for Displaying the result. 10 points
Sample Run:
Input N: 3
The square of 1 is 1
The square of 2 is 4
The square of 3 is 9
2. Modify the program from number 1 by adding a class and apply the "outside of a class function". 20 points
int main()
{
int N;
cin >> N;
cout << "Input N: " << N << endl;
for (int i = 0; i < N; i++)
{
cout << "The square of " << i << " is " << i * i << endl;
}
}
Comments
Leave a comment