Answer to Question #314478 in C++ for Badlyneeded

Question #314478

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

1
Expert's answer
2022-03-19T12:24:57-0400
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;
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog