Complete program - design two recursive functions with menu:

Write a program that asks the user to input a positive integer, and then produces a menu where the user can choose to either check if the number entered is a prime number or print the sum of all the integers from 0 to the number entered. You are required to use a recursive function isPrime for checking whether the number entered is a prime number. Also you are required to use a recursive function sum to produce the summation of all integers from 0 to entered number.

## All 6 Replies

Post the code you have attempted to write and ask specific questions. We are not going to do the work for you.

This is my code.but Ican't complet it.becuse this question not easy for me and the code now correct or not??:(

``````#include <iostream>
using namespace std;
int num1;
int main(){
cout<<"Enter a positive integer number: ";
cin<<num1;
cout<<"\n\nWhat Would you like to do? Enter..\na- for checking if entered number is prime\n
cout<<" b- for printing the sum of all numbers from 0 to"<<num1;
cout<<"\nc- to exite program
``````

cin uses >> instead of <<, such as

`cin >> num1;`

Have you studied recursive functions? Did your instructor talk about them in class?

This is a good tutorial on recursion:

Hi agin!! this my code but not complete I Know .. so the error on 2 function recursion .! and my code this correct all or not !! So please tell me ..i need help.

``````#include <iostream>
using namespace std;
int x;
char choose;
int dispsum (int x );
int main(){
cout<<"Enter a positive integer number: ";
cin>>x;
cout<<"\n\nWhat Would you like to do? Enter..\n";
cout<<"a- for checking if entered number is prime\n";
cout<<"b- for printing the sum of all numbers from 0 to"<<x;
cout<<"\nc- to exite program";
cin>>choose;
char ch='c';
if(choose!=ch)
switch(choose){
case'a':
break;
case'b':
dispsum ( );
break;
default:
cout<<"Wrong Entery!!"<<endl;
}
system("PAUSE");
return 0;
}