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
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 |
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 |
What are the different types of objects used in c?
What is floating point exception error? And what are different types of errors occur during compile time and run time? why they occur?
What are c identifiers?
#include<string.h> void main() { String s1[]={"swathi"}; string s2[]={"maddimsetti"}; s1[]=s[]; printf("%s",s1[]); }
What is || operator and how does it function in a program?
What are global variables and how do you declare them?
Find the middle node in the linked list?? (Note:Do not use for loop, count and count/2)
A banker has a seif with a cipher. Not to forget the cipher, he wants to write it coded as following: each digit to be replaced with the difference of 9 with the current digit. The banker chose a cipher. Decipher it knowing the cipher starts with a digit different than 9. I need to write a program that takes the cipher from the keyboard and prints the new cipher. I thought of the following: Take the input from the keyboard and put it into a string or an array. Go through the object with a for and for each digit other than the first, substract it from 9 and add it to another variable. Print the new variable. Theoretically I thought of it but I don't know much C. Could you give me any kind of hint, whether I am on the right track or not?
What is the difference between single charater constant and string constant?
What are the keywords in c?
What should malloc() do? Return a null pointer or a pointer to 0 bytes?
what is a c-language.what is do.