Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

program to find error in linklist.(i.e find whether any node point wrongly to previous nodes instead of next node)

2061


Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]

1038


What is hashing in c language?

1222


The file stdio.h, what does it contain?

1130


What happens if you free a pointer twice?

1038


I have seen function declarations that look like this

1004


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.

4171


What are the types of variables in c?

994


Explain what is the concatenation operator?

1121


What is the purpose of realloc()?

1101


Can 'this' pointer by used in the constructor?

1054


What is a scope resolution operator in c?

1220


Why c is called object oriented language?

1020


What is %lu in c?

1197


How do I send escape sequences to control a terminal or other device?

1028