السلام عليكم
اذا احد يقدر يساعدني في حل هذا
#include <iostream.h>
const int size = 10;
class list
{
private:
int data;
int count;
public:
list()
{
count = 0;
}
void addback(int newitem)
{
data[count]= newitem;
count++;
display();
}
void deleteback()
{
count --;
display();
}
void display()
{
cout<<"\n----------\n";
for (int i = 0; i<count; i++)
cout<<data;
cout<<"\n----------\n";
}
void display_menu()
{
cout<<"\n choose number\n 1) add\n 2) delete\n 3) display\n 4)quit\n";
}
};
void main()
{
int choice, new_num;
list l1;
l1.display_menu();
cin>> choice;
while(choice != 4)
{
switch(choice)
{
case 1: cout<<"Enter number";
cin>> new_num;
l1.addback(new_num);
break;
case 2: l1.deleteback();
break;
case 3:
l1.display();
break;
}
l1.display_menu();
cin>> choice;
}
}
_________________________________________________________________
draw flowchart and write code to add new functions to:
1) sort the list
2) find the maximum number
وهذا
a) Modularize the following code:
#include <iostream>
using namespace std;
int main()
{
int x; // base
int y; // exponent
cout << "Enter the first integer: "; // prompt for x
cin >> x; // input base
cout << "Enter the second integer: "; // prompt for y
cin >> y; // input exponent
//find the x to the power of y
int i; // counts from 1 to y
int power; // used to calculate x raised to power y
i = 1; // initialize i to begin counting from 1
power = 1; // initialize power
// count from 1 to y and multiply power by x each time
while ( i <= y )
{
power *= x;
i++;
} // end while
cout <<"x to the power of y = " <<power << endl; // display result
// find the product of x and y
int product;
product = x * y;
cout <<"x * y = " << product<< endl; // display result
// find the average
int average;
average = product / 2;
cout <<"The average is: " << average<<endl; // display result
return 0; // indicate successful termination
} // end main
B) Create the Hierarchy Chart for (a)
وشكررررررررررا :wub: