In mathematics, an arithmetic progression (AP) or arithmetic sequence is a sequence of numbers such that the difference between the consecutive terms is constant. For instance, the sequence 5, 7, 9, 11, 13, 15 … is an arithmetic progression with common difference of 2.
If the initial term of an arithmetic progression is and the common difference of successive members is d, then the nth term of the sequence () is given by:
Source: wikipedia
C Program to print Arithmetic Progression:
#include <stdio.h> int main() { int i, term, difference, ap; printf("Enter number of terms: "); scanf("%d",&term); printf("Enter the common difference of Arithmatic Progression: "); scanf("%d",&difference); printf("The arithmatic progression from 1 to %d with term difference %d is: \n",term,difference); for(i=1;i<=term;i++){ ap = 1+(i-1)*difference; printf("%d ",ap); } return 0; }
All the best. It was helpful to me. Thanks. carry on, Sakib.
ReplyDeleteThanks,helped a lot.
ReplyDeleteb-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
ReplyDelete