> #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
Aug 22

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
Aug 22
#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
Aug 22
```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