Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1) Write a C++ function to print out all unique letters of a given string. You a

ID: 3753032 • Letter: 1

Question

1) Write a C++ function to print out all unique letters of a given string. You are free to use any C++ standard library function including STL and your middle school math knowledge here. Extend your function to check whether a given word is an English pangram. Test your program in a driver program and copy paste your program here:

2) Shifting each element by given amount toward the left is called "left rotation" of an array. For example, if 2 left rotations are performed on the array [1, 2, 3, 4, 5], then the array would become [3, 4, 5, 1, 2]. Given an array of integers and a number, "r" (how many rotations), perform "r" left rotations on the array. Then print the updated array as a single line of space-separated integers. Copy paste your function code here:

3) The objective of this question is to learn about ADT (abstract data type) and base classes.

How can you extend an ellipse to create a circle? Write a subclass Circle by extending your Ellipse class. Copy paste your code here:

Each question must be able to be tested succesfully and code of the succesful output should be shown.

Explanation / Answer

Q.1. (i) C++ function:

string removeDuplicate(string str){

int n=str.size();
set<char> s;
for(int j=0;j<n;j++)
s.insert(str[j]);
int i = 0;
for (auto x : s)
str[i++] = x;
str[i] = '';
return str;
}

Q.1. (ii) C++ function:

bool removeDuplicate(string str){
int n=str.size();
set<char> s;
for(int j=0;j<n;j++)
if(isalpha(str[j]))
s.insert(tolower(str[j]));
if(s.size()==26)
return true;
else
return false;
}

Q.2. C++ function:

void left_rotate(int n,int r,int a[]){ //n is the size of array
for(int i=r;i<n;i++)
cout<<a[i]<<" ";
for(int i=0;i<r;i++)
cout<<a[i]<<" ";
}

Q.3. C++ classes code:

class ellipse{
private:
double x,y; //centre coordinates
double a,b; //semi-major and semi-minor axis
public:
double pi=3.14;
double area(){
return pi*a*b;
}
double h(){
return (((a-b)*(a-b))/((a+b)*(a+b)));
}
double circum(){
return pi*(a+b)*(1+3*h()/(10+sqrt(4-3*h())));
}
ellipse(double xx,double yy,double aa,double bb){
x=xx;
y=yy;
a=aa;
b=bb;
h();
cout<<area()<<endl<<circum()<<endl;
}
};

class circle:public ellipse{
private:
double x,y; //centre coordinates
double r; //radius
public:
circle(double xx,double yy,double rr):ellipse(xx,yy,rr,rr){}
};