1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
lyudmila [28]
4 years ago
13

Write a code segment that takes an emailaddress stored in the string email and stores theuser name in the string user and the ho

staddress in the string host. Remember that the user name and host address are separated by thecharacter @.
Computers and Technology
1 answer:
iragen [17]4 years ago
8 0

Answer:

#include <bits/stdc++.h>

using namespace std;

int main() {

  string email,username,host;//strings to store email,username,hostname..

  cout<<"Enter the email address "<<endl;

  cin>>email;//taking input of email address..

  bool flag=1;

  for(int i=0;i<email.length();i++)//iterating over the string email..

  {

      if(email[i]=='@')//if @ symbol is encountered make flag 0 skip this iteration.

      {

          flag=0;

          continue;

      }

      if(flag==1)//add to username if flag is 1.

      {

          username+=email[i];

      }

      else//add tom host..

      host+=email[i];

  }

  cout<<"The username is "<<username<<endl<<"The host name is "<<host;//printing the username and hostname..

return 0;

}

Explanation:

I have taken  three strings to store the email address entered by user ,username and host to store username and host name respectively.Then I am iterating over the string email if @ is encountered then skip that iteration before that keep adding characters to username string and after that keep adding characters to host.

You might be interested in
In Java please:
topjm [15]

Answer:

import java.util.Scanner;

public class Supermarket

{

public static void main (String[] args)

{  

String item;

double pounds, ounces, price,

total, unit;

Scanner scn = new Scanner(System.in);

System.out.print("Please enter the name of item ");

item = scn.nextLine();

System.out.print("Please enter the price of "  + "the item per pound : ");

price = scn.nextDouble();

System.out.print("Enter the weight of "  + "the item in pounds and "  + "ounces respectively : ");

pounds = scn.nextDouble();

ounces = scn.nextDouble();

unit = price/16;

total = price * (pounds + ounces/16);

System.out.print("The unit price of "  + "the products sold is : "  + unit);

System.out.print("\nThe total cost of the "  + "amount purchased is : "  + total);

}

}

Explanation:

  • Ask the user to enter the price of  the item and the weight.
  • Calculate the unit and the total price.
  • Display the unit and the total price.

6 0
3 years ago
Read 2 more answers
A U.S. social security number consists of a string of 9 digits, such as "444422333". Assume that input consists of a sequence of
harkovskaia [24]

Answer:

767745089

Explanation:

6 0
3 years ago
Read 2 more answers
When you evaluate the use of digital media, how has it affected the newspaper business? The rise of digital media has caused new
Harrizon [31]

Answer:

The rise of digital media has caused newspaper subscriptions to decline significantly because people are finding their news online.

It is A

3 0
3 years ago
Identify the potential impact to IT security of incorrect configuration of firewall policies and third- party VPNs
yan [13]

Answer:

why is it necessary to fight against social evils and problem

5 0
3 years ago
Write the code to call a CSS file named "exam.css".
katen-ka-za [31]

Answer:

 <link rel="stylesheet" href="exam.css">

Explanation:

href is the file name assuming its in the same path

also get an extension called grepper, it helps debug a lot quicker

7 0
2 years ago
Read 2 more answers
Other questions:
  • Helpppppp pleaseeeeeee
    5·1 answer
  • If you have cut or copied a set of information, which procedure will NOT work to paste it back into the worksheet?
    14·1 answer
  • Which of the following is a proper use of the application NetStumbler?Which of the following is a proper use of the application
    10·2 answers
  • When executing System.out.println(a2), the toString() method in the Object class is invoked. The program cannot be compiled, bec
    11·1 answer
  • Consider an allocator on a 32-bit system that uses an implicit free list. Each memory block, either allocated or free, has a siz
    11·1 answer
  • The sun emits invisible _____&gt; A) electromagnetic waves B) Waves C) Radiation D) Wavelength E) Ultraviolet Light
    8·1 answer
  • What is website and what are the difference between website and blog pls anyone​
    6·2 answers
  • How long does it take to send a 19 MiB file from Host A to Host B over a circuit-switched network, assuming:
    14·1 answer
  • How to combine multiple documents into one pdf.
    10·1 answer
  • Collaboration software is designed to increase collaboration and productivity primarily by enabling team members to?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!