Skip to content
Programming101
Programming101

Learn everything about programming

  • Home
  • CS Subjects
    • IoT – Internet of Things
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programming101
Programming101

Learn everything about programming

C program to evaluate the geometric progression series

YASH PAL, 31 July 2024

In this tutorial, we are going to write a C Program to evaluate the geometric progression series 1/1-x=1+x+x2+x3+…+xn  in C Programming with practical program code and step-by-step full complete explanation.

C program to evaluate the geometric progression series

C Program to evaluate the geometric progression series.

 
#include<stdio.h>
#include<conio.h>

#define LOOP 100
#define ACCURACY 0.0001

void main()
{
    int n;
    float x,term,sum;

    printf("Input value of x: ");
    scanf("%f",&x);

    sum=0;

    for(term=1, n=1; n<=LOOP; ++n)
    {
        sum+=term;

        if(term<=ACCURACY)
        goto output;
        term*=x;
    }

    printf("FINAL VALUE OF N IS NOT SUFFICIENT TO ACHIEVE DESIRED ACCURACYn");

    goto end;
    output:

    printf("EXIT FROM LOOPn");
    
    end:
    
    printf("sum=%f number of terms=%d",sum,n);
 
}

Output

 
Input value of x: .21
EXIT FROM LOOP
Sum=1.265800 number of terms=7
Input value of x: .75
EXIT FROM LOOP
Sum=3.999774 number of terms=34
Input value of x:.99
FINAL VALUE OF N IS NOT SUFFICIENT TO ACHIEVE DESIRED ACCURACY
c coding problems

Post navigation

Previous post
Next post
  • How AI Is Revolutionizing Personalized Learning in Schools
  • GTA 5 is the Game of the Year for 2024 and 2025
  • Hackerrank Day 5 loops 30 days of code solution
  • Hackerrank Day 6 Lets Review 30 days of code solution
  • Hackerrank Day 14 scope 30 days of code solution
©2025 Programming101 | WordPress Theme by SuperbThemes