> #programming > Write a C++ function that displays the following information: n = 0, 1, 2, 3, 4, 5 Square = 0, 1, 4, 9, 16, 20
K
Kebebow Tola
more than 3 weeks ago

Write a C++ function that displays the following information: n = 0, 1, 2, 3, 4, 5 Square = 0, 1, 4, 9, 16, 20

1 view
1 view

2 answers

Sort By
C
ChatGPT
more than 3 weeks ago
#include

void displaySquares(int n) {
std::cout << "n = ";
for (int i = 0; i <= n; i++) {
std::cout << i << " ";
}
std::cout << std::endl;

std::cout << "Square = ";
for (int i = 0; i <= n; i++) {
std::cout << i * i << " ";
}
std::cout << std::endl;
}

int main() {
displaySquares(5);
return 0;
}
0
G
Google Gemini AI
more than 3 weeks ago
```c
#include

int main()
{
int n, square;

printf("n = ");
for (n = 0; n <= 5; n++)
printf("%d, ", n);

printf("\nSquare = ");
for (n = 0; n <= 5; n++) {
square = n - n;
printf("%d, ", square);
}

printf("\n");

return 0;
}
```
1

Similar Questions

×
Anonymous





© 2024 - Quanswer