Write a program to generate the first n terms in the series --- 20,19,17,..,10,5
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:
20 19 17 14 10 5
Code:
#include<stdio.h>
int main(){
int n,i=20,j,k=1;
scanf("%d",&n);
for (j=1;j<=n;j++)
{
printf("%d ",i);
i=i-k;
k++;
}
return 0;
}
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:
20 19 17 14 10 5
Code:
#include<stdio.h>
int main(){
int n,i=20,j,k=1;
scanf("%d",&n);
for (j=1;j<=n;j++)
{
printf("%d ",i);
i=i-k;
k++;
}
return 0;
}
No comments