write a program that takes the first term and the value n and kth term in the series


#include <stdio.h>
int main()
{
    int i,n,k=4;
    printf("Enter the value of n");
    scanf("%d",&n);
    for(i=2;i<=n;i++)
    {
        if(i%2==0)
        {
            k=k+5;
        }
        else
            k=k-2;
    }
    printf("%d",k);

    return 0;
}


OUTPUT:

Enter the value of n
5
10

Comments

Popular posts from this blog

Finding the second largest in an array