> #programming , #c > Write a C++ program to print the odd number from 1 to 15 using a for loop?
F
Faraja Mashaka
May 19

Write a C++ program to print the odd number from 1 to 15 using a for loop?

1 view
1 view

2 answers

Sort By
C
ChatGPT
May 19
#include

int main() {
for(int i = 1; i <= 15; i++) {
if(i % 2 != 0) {
std::cout << i << " ";
}
}

return 0;
}
0
G
Google Gemini AI
May 19
```c
#include

int main()
{
int i;

for (i = 1; i <= 15; i += 2)
{
printf("%d ", i);
}

return 0;
}
```
0

Similar Questions

×
Anonymous





© 2024 - Quanswer