Skip to content
Programmingoneonone
Programmingoneonone

Learn everything about programming

  • Home
  • CS Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
    • Cybersecurity
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programmingoneonone
Programmingoneonone

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 solutions

Post navigation

Previous post
Next post

Are you a student and stuck with your career or worried about real-time things, and don't know how to manage your learning phase? Which profession to choose? and how to learn new things according to your goal, and land a dream job. Then this might help to you.

Hi My name is YASH PAL, founder of this Blog and a Senior Software engineer with 5+ years of Industry experience. I personally helped 40+ students to make a clear goal in their professional lives. Just book a one-on-one personal call with me for 30 minutes for 300 Rupees. Ask all your doubts and questions related to your career to set a clear roadmap for your professional life.

Book session - https://wa.me/qr/JQ2LAS7AASE2M1

Pages

  • About US
  • Contact US
  • Privacy Policy

Follow US

  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2026 Programmingoneonone | WordPress Theme by SuperbThemes