بســم الله الـرحمــن الرحيــم
السلام عليكــم ورحمـة الله وبركاتــة
أنا أدرس في بريطانيا قسم
ICCT
وناخذ برنامج
C++
وطلبوا مننا هذا
Project 3 – Fibonacci Series
Modify your program further to add a third option – the Fibonacci Series. As before, you need to ask for the number of values to display.
The Fibonacci Series is a series of numbers which starts with 1, 1 and then each number is the sum of the previous two. For example,
1, 1, 2, 3, 5, 8, 13, 21, 34, 55
Quick Hint: The loop should start from the third number onwards – otherwise you can't compute the sum of the previous two numbers.
Project 4 – The Golden Ratio
Modify your Fibonacci Series to display the ratio of each pair of numbers – it doesn't matter whether you divide the first by the second or vice-versa.
What do you notice about this ratio? Does it look like its converging to a particular number?
(Anyone who has seen/read the DaVinci Code should recognise this)
اوكي انا اشتغلت عليه و طلعت الكود الي هو اتاشمنت ممكن تتطلعون عليه
#include <stdlib.h>
#include <stdio.h>
#include <iostream>
int main()
{
char line[40];
int choice;
int numNumbers, interval;
int count, result, sum;
int result2, last, next, sum1;
float ratio;
printf( "Please choose which number series you would like to display:\n" );
printf( " 1. Arithmetic Series\n" );
printf( " 2. Factorial Series\n" );
printf( " 3. Fibonacci Series\n" );
gets( line );
choice = atoi( line );
if( choice == 1 )
{
/* We are going to do a simple geometric series */
printf( "How many numbers do you want?\n" );
gets( line );
numNumbers = atoi( line );
printf( "Please enter the interval:\n" );
gets( line );
interval = atoi( line );
count = 1;
result = 1;
sum = 0;
while( count <= numNumbers )
{
printf( "Number %3d is %d\n", count, result );
sum = result + sum;
result = result + interval;
count = count + 1;
}
printf( "Number sum is %d\n", sum );
}
else if (choice == 2 )
{ printf( "How many numbers do you want?\n" );
gets( line );
numNumbers = atoi( line );
count = 1;
result2 = 1;
while ( count <= numNumbers )
{
printf( "Number %3d is %d\n", count, result2 );
count = count + 1;
result2 = count * result2;
}
}
else if (choice == 3)
{ printf( "How many numbers do you want?\n" );
gets( line );
numNumbers = atoi ( line );
next = 0;
last = 1;
count = 1;
while ( count <= numNumbers )
{
sum1 = next + last;
printf( "Number %3d is %d\n", count, sum1 );
next = last;
last = sum1;
ratio = sum1/next;
count = count + 1;
printf( " The ratio is %.2f\n", ratio);
}
}
else
{
printf( "You entered an invalid choice.\n" );
}
return( 0 );
}
طيب ممكن تتاكدولي او احد يساعدني الكود ما يطلع اي
error
والحمدالله لكن مو الجواب الي انا ابي انا ابي يطلع الراشيو ارقام و معاها كسور بس يطلعلي ارقام و جنبها اصفار ممكن مساعدة بس تعرفوني وين الغلط في الكود وشكرا

