Program to print non square numbers | CPP program to print first n non square number ; Print curr_count numbers . curr_count is current gap between two square numbers . ; skip a square number . ; Count of next non - square numbers is next even number . ; Driver code
#include <assert.h> NEW_LINE #include <math.h> NEW_LINE #include <stdio.h> NEW_LINE void printNonSquare ( int n ) { int curr_count = 2 , num = 2 , count = 0 ; while ( count < n ) { for ( int i = 0 ; i < curr_count && count < n ; i ++ ) { printf ( " % d ▁ " , num ) ; count ++ ; num ++ ; } num ++ ; curr_count += 2 ; } } int main ( ) { int n = 10 ; printNonSquare ( n ) ; return 0 ; }