Header Ads

C program for Arithmetic Progression calculation

  1. An arithmetic progression is a sequence of numbers such that the difference of any two successive members of the sequence is a constant. For example, the sequence 1, 2, 3, 4, ... is is an arithmetic progression with common difference 1.

***************************************Program***********************************

#include<stdio.h>
#include<conio.h>
main()
{
    int a,n,d,t;
    printf("Enter the first term of your AP : ");
    scanf("%d",&a);
    printf("Enter the difference b/w terms : ");
    scanf("%d",&d);
    printf("Enter the number of terms you want to get in your AP : ");
    scanf("%d",&n);
    printf("AP of your given data is :\n%d ",a);
    while(n>=0)
    {
        t=a+d;
        printf("%d ",t);
        a=t;
        n--;
    }
    getch();
}


***************************************Output************************************

Output of AP program in C

No comments