Answer to Question #155455 in C++ for Ejaz

Question #155455

Write a program that Square n numbers & show result in Tabular form(Pass by value, Pass by reference)


1
Expert's answer
2021-01-14T16:24:08-0500
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main () {
	cout << "\n\n###########################Square of N entered numbers################################\n\n";
	int n;
	cout << "Enter n: ";
	cin >> n;
	cout << "Enter numbers: \n";
	int arr[n];
	for (int i = 0; i < n; i++) {
	   int number;
	   cin >> number;
	   arr[i] = number;
	}
	cout << "Number: ";
	for (int i = 0; i < n; i++) {
	    cout << setw(5) << arr[i];
	}
	cout << "\nSquare: ";
	for (int i = 0; i < n; i++) {
	    cout << setw(5) << pow(arr[i], 2);
	}
}

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