Future
Low Latency Developer
2
MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1
200 XP
A simple implementation of the Fibonacci number series. The Fibonacci series is formed by adding the latest two numbers to get the next one, starting from 0 and 1: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, ...
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
Download
- #include<stdio.h> /* C Standard Input and Output Library*/
- /*Variable declarations*/
- int
number_of_terms;
- int
pre_term =
0
;
- int
post_term =
1
;
- int
next_transition;
- int
loop_counter;
- int
main(
void
)
/* The main method*/
- {
- /* Brief detail on the screen about the program*/
- printf
(
" /*************************************************************************\n
* Mureithi David Wachira *\n
* P15/2204/2011 *\n
* *\n
* University of Nairobi *\n
* School of Computing & Informatics *\n
* *\n
* Course: DATA STRUCTURES AND ALGORITHMS (CSC 211) *\n
* Date: Thursday 19th September 2013 *\n
* *\n
* A program to print the fibonacci number *\n
* series *\n
* *\n
*************************************************************************/\n
"
)
;
- printf
(
"\n
Please enter the number of terms\n
"
)
;
/* Prompt to instruct user to enter an integer*/
- scanf
(
"%d"
,&
number_of_terms)
;
/* Capture of the integer by the system using function scanf()*/
- printf
(
"\n
\n
"
)
;
/* Skipping two lines*/
- for
(
loop_counter =
0
;
loop_counter <
number_of_terms ;
loop_counter++
)
- {
- if
(
loop_counter <=
1
)
- next_transition =
loop_counter;
- else
- {
- next_transition =
pre_term +
post_term;
- pre_term =
post_term;
- post_term =
next_transition;
- }
- printf
(
"%d\t
"
,
next_transition)
;
- }
- printf
(
"\n
\n
"
)
;
/* Skipping two lines*/
- return
0
;
/* An indication that the program runs successfully*/
- }
/* The end of the main method*/
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
Download
You must upgrade your account or reply in the thread to view the hidden content.