Subjects
PRICING
COURSES
Start Free Trial
Hen A.
Home tutor for more than 4 years
Tutor Satisfaction Guarantee
Basic Math
TutorMe
Question:

(4)^2^3

Hen A.

65536

C++ Programming
TutorMe
Question:

write a program that create a class called Employee that includes three pieces of information as data members—a first name (type char*), a last name (type string) and a monthly salary (type int). Your class should have a constructor that initializes the three data members. Provide a set and a get function for each data member. set it to 0.Write a test program that demonstrates class Employee’s capabilities. Create two Employee objects and display each object’s yearly salary. Then give each Employee a 10 percent raise and display each Employee’s yearly salary again

Hen A.

#include<iostream> using namespace std; class Employee{ char * first_name; string last_name; int monthly_salary; public : Employee(char *name, string l_name, int salary){ first_name=name; last_name=l_name; monthly_salary=salary; } void setfirstname(char *name){ first_name=name; } void setlastname(string l_name){ last_name=l_name; } string getfirstname() { return first_name; } string getlastname(){ return last_name; } int getsalary(){ return monthly_salary; } int salaryraise(){ return monthly_salary*0.10+monthly_salary; } int main(){ char name1[100]="Ali"; string l_name= "Murtaza"; char name2[50]="Ahmed"; char *p=name1; char *q=name2; Employee employee_one(p,l_name,2000); Employee employee_two(q,l_name,5000); cout<<"Employee one's details :"<<endl; cout<<"First name : "<<employee_one.getfirstname()<<endl; cout<<"Last Name: "<<employee_one.getlastname()<<endl; cout<<"Yearly Salary: "<<employee_one.getsalary()<<endl; cout<<"10 percent raise salary is "<<employee_one.salaryraise() <<endl<<endl; cout<<"Employee Two's details :"<<endl; cout<<"First name : "<<employee_two.getfirstname()<<endl; cout<<"Last Name: "<<employee_two.getlastname()<<endl; cout<<"Yearly Salary: "<<employee_two.getsalary()<<endl; cout<<"10 percent raise salary is "<<employee_two.salaryraise() <<endl; }

C Programming
TutorMe
Question:

Write a program that takes an input matrix with more than 2 rows and display it's mirror image using dynamic memory allocation.

Hen A.

#include<stdio.h> #include<stdlib.h> int ** matcalloc(int r,int c); void **Input(int **p,int r,int c); void **Display_matrix(int **p,int r,int c); void **Mirror(int **q,int **p,int r,int c); int main() { int row,col; do{ printf("Input Size of Rows and Cloumns:\n"); scanf("%d",&row); } while(row<=2 || row>20);{ col=row; int **p,**q; p=matcalloc(row,col); q=matcalloc(row,col); Input(p,row,col); Mirror(q,p,row,col); free(p); free(q); }return 0; } int **matcalloc(int r,int c) { int i; int **mat=(int**)calloc(r,sizeof(int*)); for(i=0;i<c;i++) { *(mat+i)=(int*)calloc(c,sizeof(int)); } return mat; } void **Input(int **p,int r,int c) { int i,j; printf("Enter elements of the matrix:\n"); for(i=0;i<r;i++) { for(j=0;j<c;j++) { scanf("%d",&p[i][j]); } } printf("Original Matrix:\n"); Display_matrix(p,r,c); } void **Mirror(int **q,int **p,int r,int c) { int k=0,i,j; for(i=0;i<r;i++) { k=0; for(j=c-1;j>=0;j--,k++) { q[i][k]=p[i][j]; } printf("\n"); } printf("mirror image Matrix:\n"); Display_matrix(q,r,c); } void **Display_matrix(int **p,int r,int c) { int i,j; for(i=0;i<r;i++) { for(j=0;j<c;j++) { printf("\t%d",p[i][j]); } printf("\n"); } }

Send a message explaining your
needs and Hen will reply soon.
Contact Hen