Program to print GP ( Geometric Progression ) | CPP program to print GP . ; function to print GP ; Driver code ; starting number ; Common ratio ; N th term to be find
#include <bits/stdc++.h> NEW_LINE using namespace std ; void printGP ( int a , int r , int n ) { int curr_term ; for ( int i = 0 ; i < n ; i ++ ) { curr_term = a * pow ( r , i ) ; cout << curr_term << " ▁ " ; } } int main ( ) { int a = 2 ; int r = 3 ; int n = 5 ; printGP ( a , r , n ) ; return 0 ; }