Advertisement

You’ve to enter the power limit of three & the output will be the summation of that numbers. Example:: If u emter the power limit 3, then it will be output as:: 1 3 9. Sum=13


#include<math.h>
#include<stdio.h>
#include<conio.h>
void main()
{  clrscr();
   int n,sum=0,i,x[500];
   printf("Enter the power limit of 3=");
   scanf("%d",&n);
   for(i=0;i<=n;i++)
   x[i]=pow(3,i);
     for(i=0;i<=n;i++)
   {printf(" %d",x[i]);}
     for(i=0;i<=n;i++)
   sum=sum+x[i];

   printf("\nsummetion=%d",sum);
   getch();
}

No comments:

Post a Comment

Please comment bellow. Share your knowledge