Home > Programming > Arithmetic Progression Generator in C

Arithmetic Progression Generator in C

This application generates an AP series using a while loop by specifying the first term, common difference and the number of terms.

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

int main(void)
{
int repeat=1;

while(repeat==1)
{

int a, d, n;
printf("Enter first term\n");
scanf("%d", &a);
printf("Enter the common difference\n");
scanf("%d", &d);
printf("Enter number of terms\n");
scanf("%d", &n);

while(n>0)
{
printf("%dt", a);
a=a+d;
n=n-1;
}

printf("\n\nRepeat[1]\nExit[0\]n");
scanf("%d", &repeat);
}
getch();
}

Download the Application (.exe)

  1. No comments yet.
  1. No trackbacks yet.