Write a c program for sum of first n terms of the series
S = 1 - (1/3) + (1/5) -(1/7) + (1/9) ......

Answers were Sorted based on User's Feedback



Write a c program for sum of first n terms of the series S = 1 - (1/3) + (1/5) -(1/7) + (1/9) ......

Answer / amitabha mukhopadhyay

void main()
{
int i,n,sum;
printf("enter n");
scanf("%d",&n);
for(i=1,i<=n,i++)
{
sum=1;
sum=sum+(-1,i)*1/(2i+1));
printf("sum=%d");
}

Is This Answer Correct ?    2 Yes 0 No

Write a c program for sum of first n terms of the series S = 1 - (1/3) + (1/5) -(1/7) + (1/9) ......

Answer / lavanya

void main()
{
int i,n,sum;
printf("enter n");
scanf("%d",&n);
for(i=1,i<=n,i++)
{
sum=1;
sum=sum+(1%(2i+1));
printf("sum=%d");
}

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More C Interview Questions

write an algorithm and a program to count the number of elements in a circularly singly linked list

1 Answers   Ignou,


how to add numbers without using arithmetic operators.

14 Answers   TCS,


Can you add pointers together? Why would you?

0 Answers  


What is d'n in c?

0 Answers  


Explain what is a pragma?

0 Answers  






What is double pointer in c?

0 Answers  


why division operator not work in case of float constant?

2 Answers  


int *p=20; if u print like dis printf("%d",p); o\p:- 20; how is it possible? plz give me the explanation.

15 Answers   Global Edge,


what is y value of the code if input x=10 y=5; if (x==10) else if(x==9) elae y=8; a.9 b.8 c.6 d.7

4 Answers   TCS,


What is the difference between arrays and pointers?

0 Answers  


how can i include my own .h file EX:- alex.h like #include<alex.h>, rather than #include"alex.h"

1 Answers  


int i=0,j; j=++i + ++i ++i; printf(" %d",j);

2 Answers   ME,


Categories