Hello every body
The doctor gave us to solve this assignment i tried to solve it but i could not can you tell me how i solve it please
the assignment is attached
and this is my code:

#include <iostream>
#include <iomanip> //FOR SETW 
#include <climits>

using namespace std;

void Primes(int);
void Fibonacci(int);
void Menu(int& c);
void GetN(int& n);
bool IsPrime(int);
int i;


void main()
{//main
	int choice, n;

	do
	{//do

        Menu(choice);

		switch(choice)
	      {//switch

		        case 1:
					cout<<"primes:";
					GetN(n);
		             Primes(n);
		               break;
	    
		        case 2:
	                    cout<<"fibonacci:";
					     GetN(n);
		                   Fibonacci(n);
		                   break;
	    
	             case 3:   break;
	
                 default: cout<<"Invalid menu option. Try again!\n\n";

		 
	      }//switch
	
	}//do
	   while (choice!=3);

}//main


void Menu(int& c)
{//MENU
   cout<<"======================================"<<endl;
   cout<<setw(15)<<"Print Series"<<endl;
   cout<<"======================================"<<endl;
   cout<<setw(3)<<"(1)"<<setw(3)<<"Primes Series"<<endl;
   cout<<setw(3)<<"(2)"<<setw(3)<<"Fibonacci Series"<<endl;
   cout<<setw(3)<<"(3)"<<setw(4)<<"Exit"<<endl;
   cout<<"======================================"<<endl;
   cout<<"Enter your selection (1,2,3): ";
   cin>>c;
   

}//MENU

void GetN(int& n)
{//reads and returns a user entered word
	cout<<"Enter the number of terms: ";
	cin>>n;

	while (n<=0)
	{
      cout<<"Enter the number of terms: ";
	cin>>n;
	}
	
}
void Primes (int n)
{//PRIMES
	
/*	IsPrime(n);

	while (IsPrime(n))
	{//WHILE
	if (IsPrime(n)==true)
	{//IF
          for (int row = 0; row < n/5 ; row++)
    {//FOR				
            for (int col = 0; col < 5; col++)
            {//FOR
                cout << col;
             }//FOR
            cout << endl;
    }//FOR
	}//IF
	IsPrime(n);
	}//WHILE
*/
int pcount(0), count(0);
	for( int i=0; count < n/5; count++)
	{
		while (IsPrime(i) && pcount < 5)
		{
			cout<<i<<"   ";
			i++;
			pcount++;
		}
		cout<<endl;
	}
}//PRIMES

bool IsPrime(int n)
{
   for (int i=n-i ; i>1 ; i--)
    {//FOR
	   if(n%i==0)
		   return false; 
    }//FOR
   return true;
}		



void Fibonacci(int n)
{
	int num1 =-1;
	int num2 =1;
    int num3, row, col, count(0);
       
        for (int row = 0; row < n/5 ; row++)
           {//FOR				
              for (int col = 0; col < 5; col++)
                {//FOR
                
				 num3  = num1+num2;

				 if (num3 < INT_MAX && num3 > INT_MIN)

				      { 
						  cout<<setw(10)<<num3<<setw(24) ;
						  count ++;
						  num1 = num2;
	                       num2 = num3;
				 }   
					 
				 else
					 
					 break;

             }//FOR
            cout << endl;

          }//FOR
			cout<<"Fibonacci Series term exceeds C++ INT_MAX value after"<<count<<endl;

	
}

Recommended Answers

All 5 Replies

come on please help me I must submit it after tomorrow
I don't have enough time
please just give me the correction of my code

>> come on

Too pushy.

>> I must submit it after tomorrow

Not our problem.

>> I don't have enough time

Tough. If I was going to help you before, now I won't.

>> please just give me the correction of my code

Again, too pushy. Note that this post is within an hour of the original. It's a self-entitled post even if it wasn't within an hour, but it's really bad within an hour.

>> up

Nope.

>> up

You're now on my "Never help under any conditions" list. Read this link.

http://www.catb.org/~esr/faqs/smart-questions.html

@VernonDozier,

Thanks so much for that link. When I installed Linux, I forgot to backup my bookmarks and lost that page. Cookie for you, bro.

@destroyer89100,

Do you enjoy programming? That's a relatively simple problem and the fact that you don't want to put the (small) amount of time necessary to do a good job makes me think you're not all that into it.

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.