c program to manipulate x=1+3+5+...+n using recursion

Answer Posted / boni ravi

#include<stdio.h>
#include<conio.h>
main()
{
int i,n;
int x=0;
clrscr();
printf("enter n value");
scanf("%d",&n);
for(i=1;i<=n;i=i+2)
{
x=i+x;
}
printf("output is%d",x);
}

Is This Answer Correct ?    9 Yes 10 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a struct c#?

609


Write a program to swap two numbers without using third variable in c?

626


How can you increase the size of a dynamically allocated array?

655


What is oops c?

625


Write a program to print factorial of given number without using recursion?

580






Explain what is wrong in this statement?

645


Why is #define used?

801


What is the purpose of clrscr () printf () and getch ()?

607


Linked list is a Linear or non linear explain if linear how it working as a non linear data structures

1773


In this problem you are to write a program that will cut some number of prime numbers from the list of prime numbers between 1 and N.Your program will read in a number N; determine the list of prime numbers between 1 and N; and print the C*2 prime numbers from the center of the list if there are an even number of prime numbers or (C*2)-1 prime numbers from the center of the list if there are an odd number of prime numbers in the list.

1393


In a switch statement, explain what will happen if a break statement is omitted?

643


Explain how do you determine a file’s attributes?

601


I have seen function declarations that look like this

610


What is the size of enum in c?

631


The % symbol has a special use in a printf statement. Explain how would you place this character as part of the output on the screen?

673