Geometric Progression in C Programming Language

 #include   <stdio.h>

#include   <math.h>


int  main() {

printf( "Geometric Progression : \n" );

printf( "\n" );


float   firstTerm = 7;

float   commonRatio = 0.8;

int   numberOfTerms = 11;

float  ithTerm;

int  i;


printf( "first term : %f \n" , firstTerm);

printf( "common ratio : %f \n" , commonRatio);

printf( "number of terms : %d \n" , numberOfTerms);

printf( "\n" );


//Geometric Progression

printf( "Geometric Progression : \n" );

for  (i = 0; i < numberOfTerms; i++)

{

ithTerm = firstTerm*pow(commonRatio, i);

printf( "%f \n" , ithTerm);

}

printf( "\n" );


return  0;

}

You may like these posts