Help me answer some questions :)

Hello again,

1) Explain briefly what the program does. Please see program code below.
2) Make a structure chart for the program code given, . (ILLUSTRATION) stating the flow of the program.
3) Revise a problem statement for the CODE.
4) Enumerate the functions used in the program. Briefly describe the purpose of the function.
5) What is the Output on the screen if you enter the following?
5.a. Enter Choice (1 or 2): 3
5.b. Enter Choice (1 or 2): 1
5.c. ****>Enter your integer: -72
5.d. ****>Enter your integer: 3
5.e. Do you want to continue? (y/n): y
5.f. Enter Choice (1 or 2): 2
5.g. ****>Enter beginning of range: -7
****>Enter end of range: 17
5.h. ****>Enter beginning of range: 1
****>Enter end of range: 10
5.i. Do you want to continue? (y/n): n
6) What is the over-all output on screen? You assume all inputs are correct. Show the output when you enter 1. And show the output when you enter 2. And ranges from 1 to 10.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158

#include<iostream.h>
#include<conio.h>
#include<math.h>

void print_menu();
int enter_choice();
void process_choice(int number);


void main()
{ int choice;
  char want_to_cont;
 do{ clrscr();
  want_to_cont='y';
  {
    print_menu();
    choice=enter_choice();
    process_choice(choice);
    cout<<endl<<"\nDo You Want To Continue?(y/n):";
    cin>>want_to_cont;
  }
   }while(want_to_cont=='y');
}
///////////////////////////////////////////////////////////////////////
void print_menu()
{
 clrscr();
 cout<<"\n********************MENU********************";
 cout<<"\n*                                          *";
 cout<<"\n*GUESS WHAT I AM DOING?           Enter---1*";
 cout<<"\n*                                          *";
 cout<<"\n*HOW ABOUT THIS CHOICE?WHAT DOES IT DO?---2*";
 cout<<"\n*                                          *";
 cout<<"\n********************************************";
 }
///////////////////////////////////////////////////////////////////////
 int enter_choice()
 {
   int selection;
   char correct_choice;
   correct_choice='n';
   while(correct_choice=='n')
    {
     cout<<"\nENTER CHOICE(1 or 2):";
     cin>>selection;
       if(selection==1)
	 correct_choice='y';
       if(selection==2)
	 correct_choice='y';
     }
      return selection;
 }
///////////////////////////////////////////////////////////////////////
 void process_choice(int alternative)
 {
   int value;
   char prime;
   int beginning;
   int end;

   int entered_integer();
   char is_prime(int number);
   void determine_prime(int start,int end);

   if (alternative==1)
    {
      cout<<"\nYou want to determine if your integer is prime.";
      value=entered_integer();
      prime=is_prime(value);
       if(prime=='y')
	cout<<endl<<value<<" is a prime number";
       else
	cout<<endl<<value<<" is not prime";
      }




(PAGE2)

 else
     {
      cout<<"\n You want to determine all prime integers in a range.";
      cout<<"\n***>Enter Beginning of Range:";
      cin>>beginning;
      cout<<"\n***>Enter End of Range:";
      cin>>end;

      if(beginning<=end)
	 { if(beginning>=1)
	    {
	      cout<<"\n Prime numbers between "<<beginning<<" and "<<end<<":";
	      determine_prime(beginning,end);
	    }
	   else

	     cout<<"\nBeginning and End of range should be POSITIVE!";
	 }
      else
	  cout<<"\nIncorrect range of Specification";

   }}
///////////////////////////////////////////////////////////////////////
int entered_integer()

{
  char positive_number;
  int number;

  positive_number='n';
  while(positive_number=='n')
  {
     cout<<"\n****>ENTER YOUR INTEGER:";
     cin>>number;

     if(number>0)
	 positive_number='y';
     else
	cout<<"You should enter a Positive Integer.";
  }
  return number;
}
///////////////////////////////////////////////////////////////////////
char is_prime(int number)
{
  int limit;
  int denum;
  char prime;

  limit=sqrt(number);
  denum=2;
  prime='y';
    while(denum<=limit)
     {
       if(number%denum==0)
	  prime='n';
	  denum=denum+1;
     }
  return prime;
}
///////////////////////////////////////////////////////////////////////	
void determine_prime(int star_of_range,int end_of_range)
{
   int count;
   char prime;

   count=star_of_range;
   while(count<=end_of_range)
    {
      prime=is_prime(count);
      if(prime=='y')
	cout<<"\n   "<<count;
	count+=1;
    }
   }

Smells like homework/quiz to me. Sorry. Don't do others' homeworks. In any case, you should be able to compile and run this instead of asking. What prevents you from actually trying this out in a compiler?
Topic archived. No new replies allowed.