text: Print squares of first n natural numbers without using * , / and | C ++ program to print squares of first ' n ' natural numbers wothout using * , / and - ; Initialize ' square ' and first odd number ; Calculate and print squares ; Print square ; Update ' square ' and ' odd ' ; Driver program to test above function
code: #include <iostream> NEW_LINE using namespace std ; void printSquares ( int n ) { int square = 0 , odd = 1 ; for ( int x = 0 ; x < n ; x ++ ) { cout << square << " ▁ " ; square = square + odd ; odd = odd + 2 ; } } int main ( ) { int n = 5 ; printSquares ( n ) ; }