# data[].attributes.body
Why? (Urgent)
Besok bentang Projek  pukul 14.30 di MP1.

# data[].attributes.attachment_link.readable_text

// parking system :
// operating time 10.00 - 22.00 every day.
// the first two hours everycar will be charge RM 2.00.
// the next hour will be charged RM 1.00 .
// there are 100 parking spaces available.
// if the parking spaces are full, then the customer's car is not allow to enter the parking area.


// at the end of the operation the system has ability:
// to calculate the amount of RM got on that day.
// total number of cars parked at the parking area.


#include <iostream> 
#include <string>
using namespace std;


struct waktu
{
int jam; // hour 0..23
int minit; // minute 0.59
int saat; // second 0.59

};

struct kereta
{
string platenumber;
waktu masuk;
waktu keluar;

};

int const SIZE = 100;
kereta parks[SIZE];
int total_number_of_parked_kereta;
int get_integer_number();
void set_waktu(waktu &w);
void show_waktu(waktu w);
void set_kereta_masuk(kereta &k);
void set_kereta_keluar(kereta &k);

bool search_kereta (int &indexWanted);


int main()
{
	char choice;
	waktu masuk, keluar;
	kereta theKereta;
	int total_number_of_parked_kereta=0;
	int total_number_of_cars=0;
	int indexWanted;
	
	do
	{
		cout<<"\n\t\t Welcome to Car Parking System "<<endl;
		cout<<"\n 1 - Kereta Masuk "<<endl;
		cout<<"\n 2 - Kereta Keluar "<<endl;
		cout<<"\n 3 - EXIT "<<endl;
		 
		 cout<<"\n\t Please Enter Your Choice - "<<endl;
		 cin>>choice;
		switch(choice)
		{
			case '1';
				cout<<"\n\t 1- Kereta Masuk"<<endl;
				if(total_number_of_parked_kereta<SIZE)
				{
					set_kereta_masuk(theKereta);
					show_waktu(theKereta.masuk);
					parks[total_number_of_parked_kereta];
					total_number_of_parked_kereta++;
					 total_number_of_cars++;
				}
				else
				
			break;
			
			case '2';
				cout<<"\n\t 2 - Kereta Keluar"<<endl;
			break;
			
			case '3';
				cout<<"\n\t 3 - EXIT"<<endl;
			break;
			
			default;
				cout<<"\n\t Don't enter wrong NUMBER !!!!!!"<<endl;
		}
	}while(choice!='3');
	

	return 0;
}
void set_waktu (waktu &w)
{
	int hour = 0 ,min = 0 ,sec = 0;

	do 
	{
	
		cout << "Enter jam ";
		cin >> hour;
	}
	while (hour>0 || hour<23);
	do
	{
		cout << "Enter minute";
		cin >> min;
		
	} while (min<0 || min>59 );
	do
	{
		cout << "enter saat";
		cin >> sec;

	} while (sec<0 || sec> 59);

		w.jam = hour;
		w.minute= min;
		w.saat = sec;

}

waktu subtract_waktu (waktu masuk, waktu keluar)
{
		double cost = 2;
		int jam;

		cout << "\n\t Enter your entry hour :";
		cin >> masuk.jam;
		cout << "\n\t Enter your exit hour:";
		cin >> keluar.jam;
		 
		if (jam >=2)
		{
			
			int sisa; 
			int tambahan;

			sisa = jam -2 ;
			tambahan = sisa * 1;

			cost = cost+tambahan;

			cout << "Total parking charges is :" << cost << ".00" << endl;
			cout << "Total parking period is :" << jam<< endl;
		}
}

bool search_kereta (int &indexWanted)
{
	bool found= false;
	string plateNumber;
	cout<<"\n\t Enter plate NUMBER ";
	cin>>plateNumber;
	for(int i=0;i<total_number_of_parked_kereta;i++)
	{
		if(parks[i].platenumber==plateNumber)
		{
			indexWanted=i;
			break;
		}
	}
return found;
}

void set_kereta_keluar(kereta &k)
{
	cout<<"\n\t Enter plate NUMBER = ";
	cin.ignore();
	getline(cin,platenumber);
	
	cout<<"\n\t Enter entry TIME = ";
	set_waktu(k.keluar);
}

void set_kereta(kereta &k)
{
	cout<<"\n\t Enter Your Plate Number = ";
	cin>>k.platenumber;
	
	cout<<"\n\t Enter entry TIME = ";
	set_waktu(masuk);
	k.masuk=masuk;
}

    

# data[].attributes.attachment_link.readable_text

#include <iostream>
#include <string>
using namespace std;

void generate_grade(float KK, float PA, string &grade);
float convert_grade_to_points(string grade);
float calculate_points (string grade, int credit);
float calculate_gpa(float total_points, int total_credits);
void setKKs(float kerja_kursus[], int size);
void setPAs(float peperiksaan_akhir[], int size);
void setCH(int CH[], int size);
void setGrades(string Grades[], 
		float kerja_kursus[], 
		float peperiksaan_akhir[], 
		int SIZE);

const int SIZE = 5;

int main()
{

	
	float KKs[SIZE];
	float PAs[SIZE];
	int Credit_Hours[SIZE];
	string Grades[SIZE];
	float total_points;
	int total_credits;

	// you can add any variables below:

	setKKs(KKs, SIZE);
	setPAs(PAs, SIZE);
	setCH(Credit_Hours, SIZE);
	setGrades(Grades, KKs, PAs, SIZE);

	//..... you can add any line of codes below:

	cout << "\n\t Your GPA = " 
		<< calculate_gpa(total_points, total_credits)
		<< endl << endl;


 return 0;
}

//function implementations/definition/bodies:

void generate_grade(float KK,float PA, string grade)
{ 
	int score;
	score = KK + PA;
	{
		if (score>= 80)
		grade = "A";
		else if(score>= 75)
		grade = "A-";
		else if(score>= 70)
		grade = "B+";
		else if(score>= 65)
		grade = "B";
		else if(score>= 60)
		grade = "B-";
		else if(score>= 55)
		grade ="C+";
		else if(score>= 50)
		grade ="C";
		else if(score>= 47)
		grade ="C-";
		else if(score>= 44)
		grade ="D+";
		else if(score>=40)
		grade ="D";
		else
		grade ="E";
	}
}




float convert_grade_to_points(string grade)
{
	float points = 0.0;
	{
		if (grade>= "A")
		    points = 4.0;  
		else if (grade>= "A-")
			points = 3.7;
		else if (grade>= "B+")
			points = 3.3;
		else if (grade>= "B")
			points = 3.0;
		else if (grade>= "B-")
			points = 2.7;
		else if (grade>= "C+")
			points = 2.3;
		else if (grade>= "C")
			points = 2.0;
		else if (grade>= "C-")
			points = 1.7;
		else if (grade>= "D+")
			points = 1.3;
		else if (grade>= "D")
			points = 1.0;
		else
			points = 'E';
	}
	return points;
}




float calculate_points(string grade, int creadit)
{

	float points = 0.0;

	return points;
}



float calculate_gpa(float total_point, int total_creadits)
{

	float gpa = 0.0;
	      
	return gpa;
}


/*
Relation between Marks and Grade:
mark >= 80 -->A
	
mark >= 75 --> A-

mark >= 70 --> B+	
mark >= 65 --> B
mark >= 60 --> B-
mark >= 55 --> C+	
mark >= 50 --> C
mark >= 47 --> C-
mark >= 44 --> D+
mark >= 40 --> D
mark >= 0 --> E
*/


	
	
    
    

# data[].attributes.attachment_link.readable_text

#include <iostream>
#include <string>
using namespace std;

void generate_grade(float KK, float PA, string &grade);
float convert_grade_to_points(string grade);
float calculate_points (string grade, int credit);
float calculate_gpa(float total_points, int total_credits);
void setKKs(float kerja_kursus[], int size);
void setPAs(float peperiksaan_akhir[], int size);
void setCH(int CH[], int size);
void setGrades(string Grades[], 
		float kerja_kursus[], 
		float peperiksaan_akhir[], 
		int SIZE);

const int SIZE = 5;

int main()
{

	
	float KKs[SIZE];
	float PAs[SIZE];
	int Credit_Hours[SIZE];
	string Grades[SIZE];
	float total_points;
	int total_credits;

	// you can add any variables below:

	setKKs(KKs, SIZE);
	setPAs(PAs, SIZE);
	setCH(Credit_Hours, SIZE);
	setGrades(Grades, KKs, PAs, SIZE);

	//..... you can add any line of codes below:

	cout << "\n\t Your GPA = " 
		<< calculate_gpa(total_points, total_credits)
		<< endl << endl;


 return 0;
}

//function implementations/definition/bodies:

void generate_grade(float KK,float PA, string grade)
{ 
	int score;
	score = KK + PA;
	{
		if (score>= 80)
		grade = "A";
		else if(score>= 75)
		grade = "A-";
		else if(score>= 70)
		grade = "B+";
		else if(score>= 65)
		grade = "B";
		else if(score>= 60)
		grade = "B-";
		else if(score>= 55)
		grade ="C+";
		else if(score>= 50)
		grade ="C";
		else if(score>= 47)
		grade ="C-";
		else if(score>= 44)
		grade ="D+";
		else if(score>=40)
		grade ="D";
		else
		grade ="E";
	}
}




float convert_grade_to_points(string grade)
{
	float points = 0.0;
	{
		if (grade>= "A")
		    points = 4.0;  
		else if (grade>= "A-")
			points = 3.7;
		else if (grade>= "B+")
			points = 3.3;
		else if (grade>= "B")
			points = 3.0;
		else if (grade>= "B-")
			points = 2.7;
		else if (grade>= "C+")
			points = 2.3;
		else if (grade>= "C")
			points = 2.0;
		else if (grade>= "C-")
			points = 1.7;
		else if (grade>= "D+")
			points = 1.3;
		else if (grade>= "D")
			points = 1.0;
		else
			points = 'E';
	}
	return points;
}




float calculate_points(string grade, int creadit)
{

	float points = 0.0;

	return points;
}



float calculate_gpa(float total_point, int total_creadits)
{

	float gpa = 0.0;
	      
	return gpa;
}


/*
Relation between Marks and Grade:
mark >= 80 -->A
	
mark >= 75 --> A-

mark >= 70 --> B+	
mark >= 65 --> B
mark >= 60 --> B-
mark >= 55 --> C+	
mark >= 50 --> C
mark >= 47 --> C-
mark >= 44 --> D+
mark >= 40 --> D
mark >= 0 --> E
*/


	
	
    
    

# data[].attributes.body
function 1

# data[].attributes.attachment_link.readable_text
#include <iostream>
using namespace std;

float Input_working_hour();
float calculate_salary(float work_hour);
void Display_salary (float salary);

void main()
{
	float working_hour;
	float salary;

	working_hour = input_hour();
	salary = calculate_salary(working_hour);
	Display_salary(salary);
}

float Input_working_hour()
{
	float hour;
	cout <<"\n\t Please enter staff working hour :" << endl;
	cin >> hour;
	return hour;
}

float calculate_salary(float hour)
{
	float salary;
	salary = hour*7.5;
	return salary;
}

void Display_salary(float salary)
{
	cout<<"\n\t Your salary for this month is:"<<salary<<endl;
}



# data[].attributes.body
Iterative Factorial

# data[].attributes.attachment_link.readable_text
#include <iostream>
using namespace std;

int recursiveFact(int number);
int iterativeFact1(int number);//using while loop
int iterativeFact2(int number);//using do while loop
int iterativeFact3(int number);//using for loop


int main()
{
	int number = 0;
	do
	{
		cout << "\n\t Enter integer number =";
		cin >> number;
		if (number >=0)
		{
	    cout <<"\n\t Result " << number << "! = " << recursiveFact(number);
		cout <<"\n\t Result " << number << "! = " << iterativeFact1(number);
		cout <<"\n\t Result " << number << "! = " << iterativeFact2(number);
		cout <<"\n\t Result " << number << "! = " << iterativeFact3(number);
	    }
	}while (number >=0);

	return 0;
}//end main

int iterativeFact1(int number)
{
	int result = 1;
	int index = 1;

	while (index <=number)
	{
		result *= index;
		++index;
	}
	
	return result;
}//end int iterativeFact1(int number);//using while loop

int iterativeFact2(int number)
{
	int result = 1;
	if(number > 0 )
	{
       do 
		{
			result = result * number;
			number--;
		}while (number > 0);
	}
	
	return result;
}//end int iterativeFact2(int number);//using do while loop

int iterativeFact3(int number)
{
	int result = 1;
	int index;
	
	for(int index =1; index <= number; index++)
	{
		result = result * index;
	}

	return result;
}//end int iterativeFact3(int number);//using for loop



int recursiveFact(int number)
{
	int result;

	if (number < 0)
	{
		cout <<"\n\t no result for negative number....!" << endl <<endl;
	}
	else if (number == 0 || number == 1)
	{
		result = 1;
	}

	else
	{
		//result result = number* number-1 * number-2;
		result = number * recursiveFact(number-1);
	}
	return result;
}

# data[].attributes.body
recursive factorial

# data[].attributes.attachment_link.readable_text
#include <iostream>
using namespace std;

int recursiveFact(int number);
int iterativeFact(int number);

int main()
{
	cout <<"\n\t Result 3! = " << recursiveFact(3);
}//end main

int iterativeFact(int number)
{
	int result = 1;

	return result;
}
int recursiveFact(int number)
{
	int result;

	if (number < 0)
	{
		cout <<"\n\t no result for negative number....!" << endl <<endl;
	}
	else if (number == 0 || number == 1)
	{
		result = 1;
	}

	else
	{
		//result result = number* number-1 * number-2;
		result = number * recursiveFact(number-1);
	}
	return result;
}

# data[].attributes.body
6.3 Exercise (page 99)
3. Write a program that can act as a calculator.
The calculator program should received two input two integers
and the operation to be performed.
It should then output the numbers, the operator, and the result.
Use while loop to repeat the calculation for other inputs
until the user choose to stop.

# data[].attributes.attachment_link.readable_text
#include <iostream>
#include <string>
using namespace std;
int main()
{
	double result = 0, counter = 0;
	char sign, Q = 0;
	double value;
		do 
		{
			cout << "Current value is " << result << endl;
			
			cout << "Please enter an operation +, -, *, / ('Q' to quit) ";
			cin >> sign;
			
			if (sign != 'Q')
			{
				cout << "Please enter a number: ";
				cin >> value;
				cin.ignore();
				 
				if (value <= 0)
				{
					cout << "ERROR! DIVIDE BY ZERO!! "; 
					cout << endl;
				}
			
				else
				{
				
				if (sign == '+')
				{
					result += value;
				}
				
				else
				{
					if (sign == '-')
					{
						result -= value;
					}
					
					else
					{
						if (sign == '*')
						{
							result *= value;
						}
						
						else 
						{
							if ((sign == '/') && (value != 0))
							{
								result /= value;
							}
							
						}
					}
				}
				}
			
		}
	}
		
		while (sign != 'Q');
		return (0);			
}

# data[].attributes.body
quiz 2

# data[].attributes.attachment_link.readable_text
/*double getMax(double array[], int size);
  double getMin(double array [], int size);
  double getAverage(double array [], int size);
  double getTotal(double array [], int size);
*/

#include <iostream>
using namespace std;

double add (double a, double b);
double substract (double a, double b);
double multiply (double a, double b);
bool divide (double a, double b, double &c);
void setArray(double array[], int size);
void showArray(double array[], int size);
void getAllInfo (double array [], int size,
	double &max, double &min, double &average, double &total);

double getMax(double array[], int size);
double getMin(double array [], int size);
double getAverage(double array [], int size);
double getTotal(double array [], int size);

int main()
{
	
	double thearray[10];
	double max, min, total, average;


	setArray(thearray, 10);
    showArray(thearray, 10);
	


	getAllInfo (thearray, 10, max,min, average, total);
	cout <<"\n\t max = "<< max << endl;
	cout <<"\n\t min = "<< min << endl;
	cout <<"\n\t average = " << average << endl;
	cout <<"\n\t total = " << total << endl;

	//how to call the functions:
	max = getMax(thearray, 10);
	min = getMin(thearray, 10);
	//total = getTotal (thearray, 10);
	//average = getAverage (thearray, 10);

	cout << "\n\t Total = " << getTotal (thearray, 10) << endl;
	cout << "\n\t Average = " << getAverage (thearray, 10) << endl;
	cout << "\n\t max = " << getMax (thearray, 10) << endl;
	cout << "\n\t min = " << getMin (thearray, 10) << endl;

	return 0;
} //end main
//function definition/body:

double getMax(double array[], int size)
{
	double max = 0;
	for (int index =0; index < size; index++)
	{
		if (array[index] > max)
			{
				max = array[index];
			}
	}
	return max;

}

double getMin(double array [], int size)
{
	double min = 0;
	for (int index =0; index < size; index++)
        {
			if (array[index] > min)
			{
				min = array[index];
			}
	}
		 return min;
}


double getAverage(double array [], int size)
{
	double average = 0;
	average = getAverage(array, size) /size;
	return average;
}

double getTotal(double array [], int size)
{
	double total = 0.0;
	for (int index =0; index < size; index++)
	{
		total = total + array[index];
	}
	return total;
}





void getAllInfo (double array [], int size,
	double &max, double &min, double &average, double &total)
{
	min = array[0];
	max = array[0];
	total = 0.0;

	for (int index =0; index < size; index++)
	{ 
		total = total + array[index];

		//to find min:

			if (array[index] < min)
			{
				min = array[index];
			}

			//to find max:
			if (array[index] > max)
			{
				max = array[index];
			}
		
	}

	average = total /size;

}//end getInfo






void showArray(double array[], int size)
{
	cout <<"\n\t element index: " ; 
	for (int index =0; index < size; index++)
	{ 
		cout <<"\n\t Enter element index " << index << " : ";
		
	}
}


void setArray(double array[], int size)
{
	for (int index = 0; index < size; index++)
	{
		cout <<"\n\t Enter element index " << index << " : ";
		cin >> array[index];
	}

}//end void setArray(int array[], int size);



        double add (double a, double b)
        {
	        double tmp;
			tmp = a + b;
			return tmp;
		}

		double substract (double a, double b)
		{
	        double tmp;
			tmp = a - b;
			return tmp;
		}

		double multiply (double a, double b)
		{
	        double tmp;
			tmp = a * b;
			return tmp;
		}

		bool divide (double a, double b, double &c)
		{
	        bool status = true;
			c = 0.0;
			if (b !=0)
			{
				c= a /b ;
			}
			else
			{
				status = false;
			cout << "\n\t divide by ZERO....!" << endl << endl;
		     }
		return status;

		}
		

# data[].attributes.body
operation process

# data[].attributes.attachment_link.readable_text
//process:
//one output/result:
//additional -> c = a+b
//subtraction -> = a-b
//multiplication -> c = a*b
//divide -> c = a/b , constraint -> b=0

#include <iostream>
using namespace std;

//function declaration
double add (double a, double b);
double substract (double a, double b);
double multiply (double a, double b);
bool divide (double a, double b, double &c);
void setArray(double array[], int size);
void showArray(double array[], int size);
void getAllInfo (double array [], int size,
	double &max, double &min, double &average, double &total);



int main()
{
	/*
	double v = 10, w = 20, x = 30, y = 40, z;

	cout<< "\n\t x + y = " << x << " + " << y << " = " << add(x,y) << endl;
	cout<< "\n\t x - y = " << x << " - " << y << " = " << substract(x,y) << endl;
	cout<< "\n\t x * y = " << x << " * " << y << " = " << multiply(x,y) << endl;


	if (divide(x,y,z))
	{
		cout<< "\n\t x / y = " << x << " / " << y << " = " << z << endl;
	}

	cout << endl << endl;
	cout << "\n\t v, w, x, y = " << v << " " << w << " " << x << " " << y << " " << endl;
	cout << "\n\t total for 4 parameters v, w, x, y: " << endl << endl;
	cout << "\n\t v + w + x + y = " << x << " + " << y << " = " << add(add(add(v,w),x),y) << endl;
	cout << "\n\t v - w - x - y = " << x << " - " << y << " = " << substract(substract(substract(v,w),x),y) << endl;
	cout << "\n\t v * w * x * y = " << x << " * " << y << " = " << multiply(multiply(multiply(v,w),x),y) << endl;
	
	z = add(v,w);
	z = add(z,x);
	z = add(z,y);

	cout << "\n\t v + w + x + y + z = " << endl;

	divide (v, w, z);
	divide (z, x, z);
	divide (z, y, z);
	cout << "\n\t v/w/x/y = " << z << endl;

	*/

	double thearray[10];
	double max, min, total, average;


	setArray(thearray, 10);
    showArray(thearray, 10);



	getAllInfo (thearray, 10, max,min, average, total);
	cout <<"\n\t max = "<< max << endl;
	cout <<"\n\t min = "<< min << endl;
	cout <<"\n\t average = " << average << endl;
	cout <<"\n\t total = " << total << endl;



	return 0;
} //end main

//function definition/body:


void getAllInfo (double array [], int size,
	double &max, double &min, double &average, double &total)
{
	min = array[0];
	max = array[0];
	total = 0.0;

	for (int index =0; index < size; index++)
	{ 
		total = total + array[index];

		//to find min:

			if (array[index] < min)
			{
				min = array[index];
			}

			//to find max:
			if (array[index] > max)
			{
				max = array[index];
			}
		
	}

	average = total /size;

}//end getInfo






void showArray(double array[], int size)
{
	cout <<"\n\t element index: " ; 
	for (int index =0; index < size; index++)
	{ 
		cout <<"\n\t Enter element index " << index << " : ";
		
	}
}


void setArray(double array[], int size)
{
	for (int index = 0; index < size; index++)
	{
		cout <<"\n\t Enter element index " << index << " : ";
		cin >> array[index];
	}

}//end void setArray(int array[], int size);



        double add (double a, double b)
        {
	        double tmp;
			tmp = a + b;
			return tmp;
		}

		double substract (double a, double b)
		{
	        double tmp;
			tmp = a - b;
			return tmp;
		}

		double multiply (double a, double b)
		{
	        double tmp;
			tmp = a * b;
			return tmp;
		}

		bool divide (double a, double b, double &c)
		{
	        bool status = true;
			c = 0.0;
			if (b !=0)
			{
				c= a /b ;
			}
			else
			{
				status = false;
			cout << "\n\t divide by ZERO....!" << endl << endl;
		     }
		return status;

		}
		

# data[].attributes.body
multiply matrix

# data[].attributes.attachment_link.readable_text

#include <iostream>
using namespace std;

void setMatrix(double matrix[][10], int rows, int columns);
void showMatrix(double matrix[][10], int rows, int columns);
void mulMatrix(double matrixA[][10], double matrixB[][10], double matrixC[][10], int rows, int columns);

//assigment1[matrix]
//void subtractMatrix(double matrixA[][10], double matrixB[][10], double matrixC[][10], int rows, int columns);
//void multiplyMatrix(double matrixA[][10], double matrixB[][10], double matrixC[][10], int rows, int columns);
//void dividedMatrix(double matrixA[][10], double matrixB[][10], double matrixC[][10], int rows, int columns);




int main ()
{
	double matrixA[10][10],matrixB[10][10],matrixC[10][10];
	cout<<"\n\t to set MatrixA element:" <<endl;
	setMatrix(matrixA,2,2);
	
	cout<<"\n\t to set MatrixB element:" <<endl;
	setMatrix(matrixB,2,2);
	mulMatrix(matrixA,matrixB,matrixC,2,2);
	
	cout<<"\n\t MatrixA :" <<endl;
	showMatrix(matrixA,2,2);
	
	cout<<"\n\t MatrixB :" <<endl;
	showMatrix(matrixB,2,2);
	
	cout<<"\n\t MatrixC :" <<endl;
	showMatrix(matrixC,2,2);
	
	return 0;
}

//function defination
void mulMatrix(double matrixA[][10], double matrixB[][10], double matrixC[][10], int rows, int columns)
{
	for (int baris=0; baris<rows;baris++)
	{
		for (int kolum=0;kolum<columns;kolum++)
		{
			matrixC[baris][kolum]=matrixA[baris][kolum]*matrixB[baris][kolum];
		}
		
	}


}//end void mulMatrix(double matrixA[][10], double matrixB[][10], double matrixC[][10], int rows, int columns)   

void showMatrix(double matrix[][10], int rows, int columns)
{
	cout<<"\t Matrix Element: "<<endl; 
	for (int baris=0;baris<rows;baris++)
	{
		for (int kolum=0;kolum<columns;kolum++)
		{
			cout<< matrix[baris][kolum]<<"\t";
		}
		cout<<endl;
	}


}//end void showMatrix(double matrix[][10], int rows, int columns)



void setMatrix(double matrix[][10], int rows, int columns)
{
	for (int baris=0; baris<rows;baris++)
	{
		for (int kolum=0;kolum<columns;kolum++)
		{
			cout << "\t Enter item [ " << baris+1<<"]["<<kolum+1<<"] :";
			cin >> matrix[baris][kolum];
		}
	}


}//end void setMatrix(double matrix[][10], int rows, int columns)
 

# data[].attributes.body
divide matrix

# data[].attributes.attachment_link.readable_text

#include <iostream>
using namespace std;

void setMatrix(double matrix[][10], int rows, int columns);
void showMatrix(double matrix[][10], int rows, int columns);
void divMatrix(double matrixA[][10], double matrixB[][10], double matrixC[][10], int rows, int columns);

//assigment1[matrix]
//void subtractMatrix(double matrixA[][10], double matrixB[][10], double matrixC[][10], int rows, int columns);
//void multiplyMatrix(double matrixA[][10], double matrixB[][10], double matrixC[][10], int rows, int columns);
//void dividedMatrix(double matrixA[][10], double matrixB[][10], double matrixC[][10], int rows, int columns);




int main ()
{
	double matrixA[10][10],matrixB[10][10],matrixC[10][10];
	cout<<"\n\t to set MatrixA element:" <<endl;
	setMatrix(matrixA,2,2);
	
	cout<<"\n\t to set MatrixB element:" <<endl;
	setMatrix(matrixB,2,2);
	divMatrix(matrixA,matrixB,matrixC,2,2);
	
	cout<<"\n\t MatrixA :" <<endl;
	showMatrix(matrixA,2,2);
	
	cout<<"\n\t MatrixB :" <<endl;
	showMatrix(matrixB,2,2);
	
	cout<<"\n\t MatrixC :" <<endl;
	showMatrix(matrixC,2,2);
	
	return 0;
}

//function defination
void divMatrix(double matrixA[][10], double matrixB[][10], double matrixC[][10], int rows, int columns)
{
	for (int baris=0; baris<rows;baris++)
	{
		for (int kolum=0;kolum<columns;kolum++)
		{
			matrixC[baris][kolum]=matrixA[baris][kolum]/matrixB[baris][kolum];
		}
		
	}


}//end void subMatrix(double matrixA[][10], double matrixB[][10], double matrixC[][10], int rows, int columns)   

void showMatrix(double matrix[][10], int rows, int columns)
{
	cout<<"\t Matrix Element: "<<endl; 
	for (int baris=0;baris<rows;baris++)
	{
		for (int kolum=0;kolum<columns;kolum++)
		{
			cout<< matrix[baris][kolum]<<"\t";
		}
		cout<<endl;
	}


}//end void showMatrix(double matrix[][10], int rows, int columns)



void setMatrix(double matrix[][10], int rows, int columns)
{
	for (int baris=0; baris<rows;baris++)
	{
		for (int kolum=0;kolum<columns;kolum++)
		{
			cout << "\t Enter item [ " << baris+1<<"]["<<kolum+1<<"] :";
			cin >> matrix[baris][kolum];
		}
	}


}//end void setMatrix(double matrix[][10], int rows, int columns)
 

# data[].attributes.body
sub matrix

# data[].attributes.attachment_link.readable_text

#include <iostream>
using namespace std;

void setMatrix(double matrix[][10], int rows, int columns);
void showMatrix(double matrix[][10], int rows, int columns);
void subMatrix(double matrixA[][10], double matrixB[][10], double matrixC[][10], int rows, int columns);

//assigment1[matrix]
//void subtractMatrix(double matrixA[][10], double matrixB[][10], double matrixC[][10], int rows, int columns);
//void multiplyMatrix(double matrixA[][10], double matrixB[][10], double matrixC[][10], int rows, int columns);
//void dividedMatrix(double matrixA[][10], double matrixB[][10], double matrixC[][10], int rows, int columns);




int main ()
{
	double matrixA[10][10],matrixB[10][10],matrixC[10][10];
	cout<<"\n\t to set MatrixA element:" <<endl;
	setMatrix(matrixA,2,2);
	
	cout<<"\n\t to set MatrixB element:" <<endl;
	setMatrix(matrixB,2,2);
	subMatrix(matrixA,matrixB,matrixC,2,2);
	
	cout<<"\n\t MatrixA :" <<endl;
	showMatrix(matrixA,2,2);
	
	cout<<"\n\t MatrixB :" <<endl;
	showMatrix(matrixB,2,2);
	
	cout<<"\n\t MatrixC :" <<endl;
	showMatrix(matrixC,2,2);
	
	return 0;
}

//function defination
void subMatrix(double matrixA[][10], double matrixB[][10], double matrixC[][10], int rows, int columns)
{
	for (int baris=0; baris<rows;baris++)
	{
		for (int kolum=0;kolum<columns;kolum++)
		{
			matrixC[baris][kolum]=matrixA[baris][kolum]-matrixB[baris][kolum];
		}
		
	}


}//end void subMatrix(double matrixA[][10], double matrixB[][10], double matrixC[][10], int rows, int columns)   

void showMatrix(double matrix[][10], int rows, int columns)
{
	cout<<"\t Matrix Element: "<<endl; 
	for (int baris=0;baris<rows;baris++)
	{
		for (int kolum=0;kolum<columns;kolum++)
		{
			cout<< matrix[baris][kolum]<<"\t";
		}
		cout<<endl;
	}


}//end void showMatrix(double matrix[][10], int rows, int columns)



void setMatrix(double matrix[][10], int rows, int columns)
{
	for (int baris=0; baris<rows;baris++)
	{
		for (int kolum=0;kolum<columns;kolum++)
		{
			cout << "\t Enter item [ " << baris+1<<"]["<<kolum+1<<"] :";
			cin >> matrix[baris][kolum];
		}
	}


}//end void setMatrix(double matrix[][10], int rows, int columns)
 

# data[].attributes.body
addmatrix

# data[].attributes.attachment_link.readable_text
#include <iostream>
using namespace std;

void setMatrix(double matrix[][10], int rows, int columns);
void showMatrix(double matrix[][10], int rows, int columns);
void addMatrix(double matrix[][10], double matrixB[][10],
 double matrixC[][10], int rows, int columns);

//assignment1:
void substractMatrix(double matrixA[][10],double matrixB[][10],
	double matrixC[][10], int rows, int columns);

void multiplyMatrix(double matrixA[][10],double matrixB[][10],
	double matrixC[][10], int rows, int columns);

void divideMatrix(double matrixA[][10],double matrixB[][10],
	double matrixC[][10], int rows, int columns);


int main()
{
	double matrixA[10][10], matrixB[10][10], matrixC[10][10];
	cout <<"\n\t To set MatrixA elements:" << endl;
	setMatrix(matrixA, 2, 2);

	cout <<"\n\t To set MatrixB elements:" << endl;
	setMatrix(matrixB, 2, 2);
	addMatrix(matrixA, matrixB, matrixC, 2, 2);

	cout <<"n\t MatrixA:"<<endl;
	showMatrix(matrixA, 2, 2);

	cout<<"\n\t MatrixB :" <<endl;
	showMatrix(matrixB,2,2);
	
	cout<<"\n\t MatrixC :" <<endl;
	showMatrix(matrixC,2,2);

	return 0;
}//end main
//function definition

void addMatrix(double matrix[][10], double matrixB[][10],
 double matrixC[][10], int rows, int columns)
{
	for (int baris = 0; baris < rows; baris++)
	{
		for (int kolum =0; kolum < columns; kolum++)
		{
			matrixC[baris][kolum] = matrixA[baris][kolum] + matrixB[baris][kolum];
		}
	}
}//end void addMatrix(double matrix[][10], double matrixB[][10],double matrixC[][10], int rows, int columns);
 


void showMatrix(double matrix[][10], int rows, int columns)
{
	cout<<"\n\t matrix elements:" <<endl;
	for (int baris = 0; baris < rows; baris++)
	{
		for (int kolum =0; kolum < columns; kolum++)
			{
			cout<< matrix[baris][kolum]<<"\t";
		}
		cout<<endl;		
	}
}//end void showMatrix (double matrix[][10], int rows, int columns);

void setMatrix(double matrix[][10], int rows, int columns)
{
	for (int baris = 0; baris < rows; baris++)
	{
		for (int kolum =0; kolum < columns; kolum++)
		{
			cout << "\t Enter item [ " << baris+1<<"]["<<kolum+1<<"] :";
			cin >> matrix[baris][kolum];
		}
	}
}//end void setMatrix (double matrix[][10], int rows, int columns);


# data[].attributes.body
matrix

# data[].attributes.attachment_link.readable_text
#include <iostream>
using namespace std;

void setMatrix(double matrix[][10], int rows, int columns);
void showMatrix(double matrix[][10], int rows, int columns);

int main ()
{
	double matrixA[10][10];
	setMatrix(matrixA,2,2);
	showMatrix(matrixA,2,2);
	
	return 0;
}

//function defination

void showMatrix(double matrix[][10], int rows, int columns)
{
	for (int baris=0; baris<rows;baris++)
	{
		for (int kolum=0;kolum<columns;kolum++)
		{
			cout<< matrix[baris][kolum]<<"\t";
		}
		cout<<endl;
	}


}//end void showMatrix(double matrix[][10], int rows, int columns)



void setMatrix(double matrix[][10], int rows, int columns)
{
	for (int baris=0; baris<rows;baris++)
	{
		for (int kolum=0;kolum<columns;kolum++)
		{
			cout << "\t Enter item [ " << baris+1<<"]["<<kolum+1<<"] :";
			cin >> matrix[baris][kolum];
		}
	}


}//end void setMatrix(double matrix[][10], int rows, int columns)

# data[].attributes.body
quiz 1

# data[].attributes.attachment_link.readable_text
#include <iostream>
using namespace std;

void add (double a, double b, double c);

int main ()
{
	double x = 10.5 ,y = 20.5,z;

	add (x, y, z);

	cout << z ;
	return 0;
}

void add (double a, double b, double c)
{
	c= a+b;
}

# data[].attributes.body
lab struct

# data[].attributes.attachment_link.readable_text
#include <iostream>
using namespace std;
#include <string>

struct Student
{
		string studentID;
		string name;
		short yearInSchool;
		double gpa;
};

Student getStudent();
void showStudent (Student student);

int main () 
{
	//Student Siti, Ali;
	Student students [2];

	/*
	Siti= getStudent();
	cin.ignore();
	Ali = getStudent();
	
	showStudent (Siti);
	showStudent (Ali);
	*/

	//to initialize student data
	for ( int counter = 0; counter < sizeof(students)/sizeof (students[0]) ; counter++)
	{
		students[counter] = getStudent();
		cin.ignore();
	}
	//to show student data:
	for ( int counter = 0; counter < sizeof(students)/sizeof (students[0])  ; counter++)
	{
		showStudent (students [counter]);
	}


	return 0;
}

//function definition:
void showStudent (Student student)
{
	cout << "\n\t Student Info  "<< endl;
	cout << "\t Matric Number : " << student.studentID << endl;
	cout << "\t Name : " << student.name << endl;
	cout << "\t Year In School :" << student.yearInSchool << endl;
	cout << "\t Student gpa :" <<student.gpa << endl;
}

Student getStudent()
{	  
	Student tempStu;
	cout << "Matric No :";
	cin>> tempStu.studentID;
	cout << "Name :";
	cin >> (tempStu.name);
	cout << "year in school :";
	cin>> tempStu.yearInSchool;
	cout << "Gpa : ";
	cin >> tempStu.gpa ;
    return tempStu;
}

# data[].attributes.body
struct array

# data[].attributes.attachment_link.readable_text
#include <iostream>
using namespace std;
#include <string>

struct Student
{
		string studentID;
		string name;
		short yearInSchool;
		double gpa;
};

Student getStudent();
void showStudent (Student student);

int main () 
{
	//Student Siti, Ali;
	Student students [2];

	/*
	Siti= getStudent();
	cin.ignore();
	Ali = getStudent();
	
	showStudent (Siti);
	showStudent (Ali);
	*/

	//to initialize student data
	for ( int counter = 0; counter < sizeof(students)/sizeof (students[0]) ; counter++)
	{
		students[counter] = getStudent();
		cin.ignore();
	}
	//to show student data:
	for ( int counter = 0; counter < sizeof(students)/sizeof (students[0])  ; counter++)
	{
		showStudent (students [counter]);
	}


	return 0;
}

//function definition:
void showStudent (Student student)
{
	cout << "\n\t Student Info  "<< endl;
	cout << "\t Matric Number : " << student.studentID << endl;
	cout << "\t Name : " << student.name << endl;
	cout << "\t Year In School :" << student.yearInSchool << endl;
	cout << "\t Student gpa :" <<student.gpa << endl;
}

Student getStudent()
{	  
	Student tempStu;
	cout << "Matric No :";
	cin>> tempStu.studentID;
	cout << "Name :";
	cin >> (tempStu.name);
	cout << "year in school :";
	cin>> tempStu.yearInSchool;
	cout << "Gpa : ";
	cin >> tempStu.gpa ;
    return tempStu;
}

# data[].attributes.body
struct

# data[].attributes.attachment_link.readable_text
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;


struct PayRoll
{
	int empNumber;
	string name;
	double hours;
	double payRate;
	double grossPay;

};



int main()
{
	PayRoll employee;
	
	cout << "Enter the employee's number = ";
	cin >> employee.empNumber;
	
	cout << " Enter the employee's Name = ";
	cin.ignore(100,'\n');
	getline(cin, employee.name);
	
	cout << "How many hours employee work ? ";
	cin >> employee.hours;
	
	cout << "What is employee hourly payRate ?";
	cin >> employee.payRate;
	
	employee.grossPay = employee.hours * employee.payRate;
	
	cout << "Rate employee's payroll data :/n";
	cout << "Name : "<< employee.name<<endl;
	cout<< "Number :" <<employee.empNumber<<endl;
	cout<< "Hours work :" << employee.hours<<endl;
	cout<<"Hourly Rate :"<< employee.payRate<<endl;
	cout<<fixed<<showpoint<<setprecision(2);
	cout<<"Gross Pay : RM "<<employee.grossPay<<endl;

	return 0;
}




# data[].attributes.body
lab pointer

# data[].attributes.attachment_link.readable_text
#include <iostream>
using namespace std;

#include <ctime>
#include <cstdlib>
int *getRandomNumbers (int number);

int main ()
{
	int* thearray;
	thearray = getRandomNumbers(10);
	
	cout<<endl<<endl;
	for (int i=0; i<10;i++)
	{
		cout<<thearray[i]<<" ";				//cout << *(thearray+i) << " ";
	}
	cout <<endl<<endl;

	return 0;
} //end main



int *getRandomNumbers (int number)
{
	int* array;
	if (number<=0)
		return NULL;
		
	array = new int[number];
	srand (time(0));
	
	for (int count = 0; count < number; count++)
		array[count]=rand() % 100+1;
	return array;
	
}
//end int *getRandomNumbers (int number)




    

# data[].attributes.body
pointer array

# data[].attributes.attachment_link.readable_text
#include <iostream>
using namespace std;

int main()
{
	int x=25;
	int *ptr;
	
	
	ptr =&x;
	cout << "the value x = " <<x<<endl;
	cout << "the address x = " <<&x <<endl;
	
	cout << "the value ptr = " <<ptr<<endl;
	cout << "the address ptr = " <<&ptr <<endl;
	cout << "content of the address ptr = " <<*ptr <<endl;
	
	*ptr = 1000;
	cout << "the valur x = " <<x<<endl;
	
	
	//array pointer
	int vals[] = {4,7,11};
	int *ptrvals;
	ptrvals = vals;
	
	
	
	cout<<"value vals = "<<vals<<endl;
	cout<<"value ptrvals = "<<ptrvals<<endl;
	
	
	//display cntent array
	cout << "content array vals = ";
	for(int index = 0; index <3; index++)
	{
		cout <<vals[index] << " ";
	}
	cout << endl<<endl;
	
	
	cout << "content array vals = ";
	for(int index = 0; index <3; index++)
	{
		cout <<*(ptrvals++) << " ";
	}
	cout << endl<<endl;
	
	return 0;
}


    

# data[].attributes.body
pointer

# data[].attributes.attachment_link.readable_text
#include <iostream>
using namespace std;

int main()
{
	int x=25;
	int *ptr;
	
	ptr =&x;
	cout << "the valur x = " <<x<<endl;
	cout << "the address x = " <<&x <<endl;
	
	cout << "the valur ptr = " <<ptr<<endl;
	cout << "the address ptr = " <<&ptr <<endl;
	cout << "content of the address ptr = " <<*ptr <<endl;
	return 0;
}

# data[].attributes.headline
Write your Final Exam Proposal and Code here

# data[].attributes.subject
Write your Final Exam Proposal and Code here

# data[].attributes.body
array