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
AnnyKZ [126]
3 years ago
10

A String variable, fullName, contains a name in one of two formats:last name, first name (comma followed by a blank), orfirst na

me last name (single blank)Extract the first name into the String variable firstName and the last name into the String variable lastName. Assume the variables have been declared and fullName already initialized. You may also declare any other necessary variables.
Computers and Technology
1 answer:
Volgvan3 years ago
8 0

Answer:

#include <iostream>

using namespace std;

int main()

{

   char fullname[30];

   string fname="",lname="";

   int i,j;

   cout<<"Enter fullname\n";

   cin.getline(fullname,30); //so that blank can be read

   for(i=0;fullname[i]!=' ';i++)

       fname+=fullname[i];   //fistname will be saved

      cout<<"\n";

   for(j=i;fullname[j]!='\0';j++)

       lname+=fullname[j];    //lastname will be saved

   cout<<"\nFirstname : "<<fname<<"\nLastname : "<<lname;

   return 0;

}

OUTPUT :

Enter fullname

John thomson

Firstname : John

Lastname : thomson

Explanation:

cin.getline() should be used instead of cin in case of strings so that space can be read otherwise after blank string will be ignored.

You might be interested in
The Internet was first used by which of the following institutions?
Phantasy [73]

Answer:

U.S Department of Defense

Explanation:

(btw nazi party was around before the internet and ended before the internet therefor couldn't be that)

5 0
3 years ago
function calculate () { var s = 2; var x = 2; var y = 3; if (x &gt; 4) { s=s+ 2; } else if ( y &gt; 4) { s=s+ 4; } else { s+=3;}
MAXImum [283]

Answer:

The output of the given JavaScript code is "5".  

Explanation:

In the given JavaScript code, a method calculate is declared, inside the method, three variable "s, x, and y" is declared, in which all variable assigns a value, that is "2, 2, and 3". In the next step, a conditional statement is defined, that check value, which can be described as follows:

  • In the, If the block, x variable checks its value is greater then 4 if it is true, it will add value 2 in s variable otherwise, it will go to else if block.
  • In this block it will check the value of y variable greater then 4 if it is true, it will add value 4 in s variable.
  • In both of the above conditions is false, it will go to else section, in this, variable  "s" add value 3 in its variable, and use an alert box to print its value.
4 0
4 years ago
import java.util.Scanner; public class TeenagerDetector { public static void main (String [] args) { Scanner scnr = new Scanner(
Sonja [21]

Answer:

import java.util.Scanner;

public class TeenagerDetector {

   public static void main (String [] args) {

       Scanner scnr = new Scanner(System.in);

       boolean isTeenager;

       int kidAge;

       kidAge = scnr.nextInt();

       

       /* Your solution goes here */

       isTeenager = (kidAge >= 13) && (kidAge <= 19);

       if (isTeenager) {

           System.out.println("Teen");

           

       } else { System.out.println("Not teen"); } } }

Explanation:

A condition which check for the teenager age and return a boolean is assigned to isTeenager.

isTeenager = (kidAge >=13) && (kidAge <= 19);

So, if the kidAge is greater than/equal to 13 and less than/19, the boolean isTeenager will be true and the program will output "Teen" else "false" will be output.

The range of age for a teenager is 13 - 19.

5 0
4 years ago
Read 2 more answers
The /home/gshant/smp directory contains several files. The directory and files need to be removed. The current working directory
kherson [118]

Explanation:

Whenever a user types in a command at the command line that is not built into the shell or that does not include its absolute path and then presses the Enter key, the shell searches through those directories, which constitute the user's search path, until it finds an executable file with that name.

3 0
3 years ago
List three tacos there are several from the opening page of the help and support center.
s344n2d4d5 [400]
Mexican tacos sascSDV
8 0
4 years ago
Other questions:
  • NASA’s long term goal is for travel in space to be as _________________ as travel across the Atlantic. However, we are _________
    10·2 answers
  • Text can be inserted into a presentation by
    7·1 answer
  • The auto fill feature of excel only allows the user to fill cells with a series using the existing formatting options of the cel
    10·1 answer
  • When activated, an Excel object has all the features of an Excel ______?
    9·2 answers
  • Remember partially filled arrays where the number of elements stored in the array can be less than its capacity (the maximum num
    14·1 answer
  • Which of the following are the benefits of using Responsive Display Ads?
    9·1 answer
  • Which two things can a user view in the Reading pane?
    6·2 answers
  • Please help coding assignments i will give brainliest :)
    6·1 answer
  • The while loop and the do loop are equivalent in their expressive power; in other words, you can rewrite a while loop using a do
    6·1 answer
  • Yeoo check dis out!!!!!! wait my full vid dont show hol on
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!