Pls help me on this.
I really dont have an idea of solving this.
Here's the question ..

1. Write a c++ program that generates the following series: 0 -1 4 -9 16 -25 36 -49 64 -81 100

and also this one

2. write a program that generates the fibonacci series: 1 1 2 3 5 8 13 up to 50th term.

I was shocked when i saw this :-O It is not yet taking up. But pls. Help me. Thanks alot..

- Nell

Recommended Answers

All 5 Replies

1. Write a c++ program that generates the following series: 0 -1 4 -9 16 -25 36 -49 64 -81 100

You simply need to print the squares of a number .
You can use square_of_num = num * num. Also every odd number has negative sign. It means if square_of_num < 0 multiply it with -1 .

2. write a program that generates the fibonacci series: 1 1 2 3 5 8 13 up to 50th term.

Loop till 50th term. Inside loop print your fibonacci number. Your logic will be that next number is equal to sum of previous two numbers . So to start with , you will have to take 2 numbers both initialized to 1.

Atleast start coding. Doesn't matter if it is wrong. We are here to help. But you need to start coding on your own first :)

Alright first things first... I see this is your first post... so

We are NOT going to give you the entire program, then you learn nothing, trying and getting some code going and asking for help with syntax, errors or middle snippets we will do any time

Ok so first problem, identify the sequence... what us different between character 1, character 2, and character 3... if you find the difference write a loop that takes a digit, adds that digit until you meet the top value (100)

The same goes for problem 2 but it is just the fibonaci seq, check google

1. Write a c++ program that generates the following series: 0 -1 4 -9 16 -25 36 -49 64 -81 100

and also this one
- Nell

Break it into two series
0 4 16 36 64 100 (square of even numbers starting from zero)
-1 -9 -25 -49 -81 (negative of square of odd numbers)
Mix both and you get the result

2. write a program that generates the fibonacci series: 1 1 2 3 5 8 13 up to 50th term.
- Nell

you need two variables, say i and j. Initially it looks like this
i = 1;
j = 1;
1. Add both and keep the sum in a variable.
2. copy j to i
3. copy sum to j and repeat the process

Break it into two series
0 4 16 36 64 100 (square of even numbers starting from zero)
-1 -9 -25 -49 -81 (negative of square of odd numbers)
Mix both and you get the result


you need two variables, say i and j. Initially it looks like this
i = 1;
j = 1;
1. Add both and keep the sum in a variable.
2. copy j to i
3. copy sum to j and repeat the process

Thanks for all the help. Im gonna try it. Ill post again and please check if its right. Thank you so much :D

for 0 -1 4 -9 16 -25 36 -49 64 -81 100

use number*number*(-1 raised to the power number)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.