Write a program to generate the first n terms in the series --- 3,9,27,81,...,...
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:
3 9 27 81 243 729
Code:
#include<stdio.h>
int main(){
int n,i,j=3;
scanf("%d",&n);
for (i=1;i<=n;i++)
{
printf("%d ",j);
j=j*3;
}
return 0;
}
No comments:
Post a Comment