You are here:

C/Fibonacci Sequence

Advertisement


Question
QUESTION: Dear Sir,

How to print Fibonacci Sequence using loop and function?

Can I install Turbo C/C++ on Windows 7? Is there any website from where I can download it?

Utkarsh

ANSWER: Hello Utkarsh

I don't know anything about how to find or install turbo C. I do know that it is a very old compiler and does not follow the current standard C++ programming language.

I recommend that you download the free visual studio 2008 express edition available at this link
http://msdn.microsoft.com/en-us/express/future/bb421473
I recommend the 2008 over the 2010 because the 2008 works better on older machines. If you have a new powerful machine, then go for the 2010.


A number in the Fibonacci sequence is the sum of the last 2 numbers. You have to keep track of three values. You have
the last fib
the current fib
the new fib

The new fib is the current fib plus the last fib. Once the new fib is calculated, the current fib value goes into the last fib, and the new fib value goes into the current fib.

Create a small function which declares the 3 variables. The last fib starts at 0. The current fib starts at 1. The new fib does not have a starting value because it will be calculated. Exercise your mind a little by trying to write the calculation steps I've described above. Put the calculation steps and a print of the fib into a loop.

If you just want the answer, I'm sure you can find it on the internet with your favourite search engine.

Best regards
Zlatko

---------- FOLLOW-UP ----------

QUESTION: Dear Sir,

I have installed Visual C++ and I don't know how to use it.
I am learning C and I want to write this application:

#include<stdio.h>
main()
{
int a,b,sum;
printf("\n Enter the numbers--");
scanf("%d%d",&a,&b);
sum=a+b;
printf("Sum=%d",sum);
}

How can I write and run this program in Visual Basic?
In college we are using Turbo C/C++. Is there any difference between between Visual C/C++ and Turbp C/C++?

Utkarsh

Answer
Hello Utkarsh

I've made a video for you to show you how to get started with Visual Studio. I'm sure you can find more and better videos on YouTube. The link to my video is here:

http://goo.gl/6SWa0

I hope it helps you to get started.

You will see some differences between the Visual Studio version of C++ and the Turbo version. The Turbo version is older and does not match the current C++ standard. You may need to find and install Turbo if you want to do your schoolwork at home. Perhaps your instructor or one of the experts based in your country can help you with that.

Best regards
Zlatko

C

All Answers


Answers by Expert:


Ask Experts

Volunteer


Zlatko

Expertise

No longer taking questions.

Experience

No longer taking questions.

Education/Credentials
No longer taking questions.

©2012 About.com, a part of The New York Times Company. All rights reserved.