219k views
3 votes
In c++,

The baby array declared below holds the birth records of the babies born at General Hospital in one day.


struct BirthRecord


{


string lastName;


string firstName;


float length;


int pounds;


int ounces;


};


birthRecord baby[30];



Write a statement to print the last name of the first baby born.

2 Answers

0 votes

Answer:

See explaination

Step-by-step explanation:

Line to print the last name of the first baby born

cout<<"The last name of the first baby born is "<<baby[0].lastName<<endl;

User Confuse
by
3.3k points
5 votes

Answer:

Check the explanation

Step-by-step explanation:

using System;

using System.Collections.Generic;

namespace Demo

{

//Written in C# programming language

struct BirthRecord

{

public string lastName;

public string firstName;

public float length;

public int pounds;

public int ounces;

};

class Program

{

static void Main()

{

List<BirthRecord> birthRecords = new List<BirthRecord>(); // List of the birthRecord

BirthRecord birthRecord1 = new BirthRecord(); //Creating Object to first birth record

birthRecord1.firstName = "Ravi";

birthRecord1.lastName = "Sankar";

birthRecord1.length = 10;

birthRecord1.pounds = 10;

birthRecord1.ounces = 10;

birthRecords.Add(birthRecord1); //Adding first record to list object

BirthRecord birthRecord2 = new BirthRecord(); // Creating Object to first birth record

birthRecord2.firstName = "Vinod";

birthRecord2.lastName = "Kumar";

birthRecord2.length = 20;

birthRecord2.pounds = 20;

birthRecord2.ounces = 20;

birthRecords.Add(birthRecord2); //Adding second record to list object

for (int i = 0; i < 1; i++) //For getting only one record for that i < 1 it will execute only one time

{

Console.WriteLine("Last name of the first baby born : " + birthRecords[0].lastName);

}

Console.ReadKey(); // For waiting result in console.

}

}

}

Kindly check the attached image below for the code output.

In c++, The baby array declared below holds the birth records of the babies born at-example-1
User Ichsan
by
3.5k points