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]
3 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]3 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
Please select the word from the list that best fits the definition<br><br> Plagiarism
Pachacha [2.7K]
The practice of taking someone else's work or ideas and passing them off as one's own.
5 0
1 year ago
Read 2 more answers
Motivation is best defined as
Talja [164]

Answer:

a

Explanation:

the reason to achieve a goal

4 0
3 years ago
Read 2 more answers
How many nibbles make one kilobyte​
Kazeer [188]
2000 nibbles I think correct me if I’m wrong
5 0
2 years ago
Read 2 more answers
Putting the word int into a code will create a string variable?
loris [4]

Answer:

Yes it will create a string variable

4 0
3 years ago
What commands does SuperKarel know that regular Karel does not?
luda_lava [24]

Answer:

turnRight and turnaround

Explanation:

The regular karel does not know these commands

5 0
2 years ago
Other questions:
  • For any element in keysList with a value greater than 50, print the corresponding value in itemsList, followed by a space. Ex: I
    8·1 answer
  • Which of the below statements describes the nature of HTML elements - check as many as apply
    6·1 answer
  • The ____________ mechanism consists of a lever arm attached to the mousetrap spring.
    15·1 answer
  • What is a CPU made of
    13·2 answers
  • ________ allows the computer to get its configuration information from the network instead of the network administrator providin
    5·1 answer
  • What is the purpose of OPPA<br>​
    13·1 answer
  • Write a program that prompts the user for the name of two files each containing a single line that represents a decimal integerc
    11·1 answer
  • Neymar machine that Run on electricity
    11·1 answer
  • Cuzzzzzzzzzzzzzzzz iiiiiiiiiiiiiiiii remember everytimeeeeeeeeee on these days that i feel like you and meeeeeeeeeeeeeee
    15·1 answer
  • After creating a webpage with html code, what do you need to do so that others can access it on the internet?.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!