Answer to Question #16609 in Action Script | Flash | Flex | ColdFusion for DAVID

Question #16609
write a program to write each term of sequence 1^x-2^x+3^x............25^x. The value of n will be entered from a keyboard(cin)
1
Expert's answer
2012-10-16T11:36:10-0400
#include <stdio.h>
#include <stdlib.h>

int main ()
{
int n;
double x=5;
printf("Enter n");
scanf("%d",&n);
double sum=0;
for (int i=1; i<n; i++){
if(i%2==0){
sum+=i/x;
}else{
sum-=i/x;
}

}
printf ("Sum= %.2f ",sum);
scanf("%d",&n);
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS