Monday 18 July 2011

Write a c program to find out the sum of in A.P. series


C Code:





#include

#include



int main(){



    int a,d,n,i,tn;

    int sum=0;



    printf("Enter
the first number of the A.P. series: ");

    scanf("%d",&a);



    printf("Enter
the total numbers in the A.P. series: ");

    scanf("%d",&n);



    printf("Enter
the common difference of A.P. series: ");

    scanf("%d",&d);



    sum
= ( n * ( 2 * a + ( n -1 ) * d )

No comments:

Post a Comment