Write a program to generate the first n terms in the series --- 6,11,21,36,56,...
Input Format:
Input consists of a single integer which corresponds to n.
Output Format:
Output consists of the terms in the series separated by a blank space.
Sample Input:
6
Sample Output:
6 11 21 36 56 81
Code:
#include<stdio.h>
int main()
{
int n,i,j=6,sum=5;
scanf("%d",&n);
for (i=1;i<=n;i++)
{
printf("%d ",j);
j=j+sum;
sum=sum+5;
}
return 0;
}
No comments:
Post a Comment