c program to manipulate x=1+3+5+...+n using recursion
Answer Posted / naresh m
main()
{
int sum=0,i;
int p,n;
printf("enter value for n");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
p=(i*2-1);
sum=sum+p;
}
printf("sum is %d",sum);
}
| Is This Answer Correct ? | 2 Yes | 5 No |
Post New Answer View All Answers
program to find error in linklist.(i.e find whether any node point wrongly to previous nodes instead of next node)
Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]
What is hashing in c language?
The file stdio.h, what does it contain?
What happens if you free a pointer twice?
I have seen function declarations that look like this
Write a program to replace n bits from the position p of the bit representation of an inputted character x with the one's complement. Method invertBit takes 3 parameters x as input character, p as position and n as the number of positions from p. Replace n bits from pth position in 8 bit character x. Then return the characters by inverting the bits.
What are the types of variables in c?
Explain what is the concatenation operator?
What is the purpose of realloc()?
Can 'this' pointer by used in the constructor?
What is a scope resolution operator in c?
Why c is called object oriented language?
What is %lu in c?
How do I send escape sequences to control a terminal or other device?