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

to hostname Write a function to_hostname that will take 1 input parameter addres

ID: 3751815 • Letter: T

Question

to hostname Write a function to_hostname that will take 1 input parameter address that contains a valid URL and will transform the URL (in-place) into its respective lower case hostname (sometimes referred as subdomain/domain). For example, if address is: "https://www.cs.uri.edu/homepage/class/csc212 ?year-2013" then the resulting value in address should be "ww.cs.uri.edu". You might want to read what is a URL? before starting your implementation void to hostname (char *address); circular prime A number is called a circular prime if all rotations of its digits form a prime. For example, the number 197 is a circular prime because all possible rotations of ts digits: [197, 971, 719] are prime numbers. Write a function circular_prime that will take a parameter n, such that e a The function must return the sum of unique sums of all subsets of length k in As an example consider the sequence A [3, -2, -1, 2]. There are 6 subsets of length k 2 in A. They are: [3,-2], [3,-1], [3,2], [-2,-1], [-2,2], and [-1,2]. Their respective sums are s-[1, 2, 5, -3, 0, 1]. Some of these sums occur more than once, others only once. The sum of unique sums in this example is 5, because the sum of all values in s, excluding reapeated values, is 5 long int unique_sums (const int *A, unsigned int n, unsigned int k)

Explanation / Answer

As per chegg guidelines i am answering the first question. Please ask the remaining questions separately

Program

#include <iostream>

using namespace std;
void to_hostname(char *);
int main()
{

char url[]="https://WWW.cs.uri.edu/homepage/class/csc212?year=2013";
to_hostname(url);
return 0;
}
void to_hostname(char *address)
{
     int i;
     string url=address;
     size_t found = url.find_first_of(":");
string protocol=url.substr(0,found);

string url_new=url.substr(found+3); //url_new is the url excluding the http part
size_t found1 =url_new.find_first_of(":");
string url1 =url_new.substr(0,found1);

size_t found2 = url_new.find_first_of("/");
string host =url_new.substr(found1+1,found2-found1-1);
string path =url_new.substr(found2);

cout<<"Host: "<<host<<endl;

for(i=0;i<=host.length();i++)
{
     if(host[i]>=65 && host[i]<=92)
     {
  host[i]=host[i]+32;
     }
}

cout<<"Lower case :" <<host;

}

Output

Host: WWW.cs.uri.edu
Lower case :www.cs.uri.edu