Question

In: Computer Science

Write a C++ Program to print the first letter of your first and last name using...

Write a C++ Program to print the first letter of your first and last name using stars.
Note:
1) Using nested For Loop
2) The number of lines is given by user.
3) Using one Outer loop to print your letters.
4) Print the letters beside each other.

Solutions

Expert Solution

#include <iostream>

using namespace std;

int main()
{
//variable declaration
int n;
  
//array declaration
string firstName[10], lastName[10];
  
//get the number of lines
cout<<"Enter the number of lines: ";
cin>>n;
  
//get user input
for(int i=0; i<n; i++)
{
cout<<"Enter the first name and last name: ";
cin>>firstName[i];
cin>>lastName[i];
}
  
//display the list of the name using *
cout<<endl<<"The list of the name is:"<<endl;
for(int i=0; i<n; i++)
{
cout<<"*";
for(int j=1; j<firstName[i].length(); j++)
{
cout<<firstName[i][j];
}
  
cout<<" *";
for(int j=1; j<lastName[i].length(); j++)
{
cout<<lastName[i][j];
}
cout<<endl;
}

return 0;
}

OUTPUT:

Enter the number of lines: 5
Enter the first name and last name: Matrix Dim
Enter the first name and last name: Aman Kapoor
Enter the first name and last name: Hi Hello
Enter the first name and last name: Ok Bye
Enter the first name and last name: Tam King

The list of the name is:
*atrix *im
*man *apoor
*i *ello
*k *ye
*am *ing



Related Solutions

Using jGRASP, write a Java program named LastnameFirstname10.java, using your last name and your first name,...
Using jGRASP, write a Java program named LastnameFirstname10.java, using your last name and your first name, that does the following: Create two arrays that will hold related information. You can choose any information to store, but here are some examples: an array that holds a person's name and an array that hold's their phone number an array that holds a pet's name and an array that holds what type of animal that pet is an array that holds a student's...
Using jGRASP, write a Java program named LastnameFirstname09.java, using your last name and your first name,...
Using jGRASP, write a Java program named LastnameFirstname09.java, using your last name and your first name, that does the following: Declare an array reference variable called myFavoriteSnacks for an array of String type. Create the array so that it is able to hold 10 elements - no more, no less. Fill the array by having each array element contain a string stating one of your favorite foods/snacks. Note: Only write the name of the snack, NO numbers (i.e. Do not...
C++ Write a program that asks a teacher to input a student’s first name, last name,...
C++ Write a program that asks a teacher to input a student’s first name, last name, and four test scores. The program should find the average of the four test scores and should then write the following information to a file named “students.txt” last_name first_name average A student's first name of “XX” should be used as a sentinel value and no numeric grades less than 0 or greater than 100 should be accepted.  The program should then read the information in...
Using c++, write a program that will display your name as a void function then will...
Using c++, write a program that will display your name as a void function then will perform the following by user-defined functions: a. to compute for the sum of two numbers (n1, n2) using function.
Select a Fortune 500 company whose name starts with the first letter in your last name...
Select a Fortune 500 company whose name starts with the first letter in your last name and obtain the company’s most recent 10-K report. (You may use the same company that you used previously.) Be sure that the company has a complex capital structure. Attach the equity section of the balance sheet and the notes relevant to answering the following questions: (a) Does the company have preferred stock and common stock (or different classes of common stock)? Do its stocks...
Let M be the integer corresponding to the first letter of your last name. For example,...
Let M be the integer corresponding to the first letter of your last name. For example, if your last name begins with "A", M=1 and if your last name begins with "Z", M=26. Let k=1/M and consider the logistic equation dy/dt = k y (M - y). Construct a single figure including Title "Logistic Equation Slope Field and Euler's Method solutions by FirstName LastName" with your actual first and last names, along the top Labels for the axes a slope...
Let M be the integer corresponding to the first letter of your last name. For example,...
Let M be the integer corresponding to the first letter of your last name. For example, if your last name begins with "A", M=1 and if your last name begins with "Z", M=26. Let k=1/M and consider the logistic equation dy/dt = k y (M - y). Construct a single figure including Title "Logistic Equation Slope Field and Euler's Method solutions by FirstName LastName" with your actual first and last names, along the top Labels for the axes a slope...
Write a simple phonebook using c++ that read text file name list.txt and has:  first name, last...
Write a simple phonebook using c++ that read text file name list.txt and has:  first name, last name, and phone number as the example: MIKEL BUETTNER 3545044 ENOCH BUGG 2856220 BRENDON LAVALLEY 433312 QUINTIN CREEK 5200413 JAMISON MILLETT 6243458 FLORENCIO PUMPHREY 3296862 DARRICK FREGOSO 6868442 TOBIAS GLASSMAN 6040564 and then ask the user to add a new contact first name, last name, and phone number and same the information into a file. Use array and pointer
5. Write a C++ statement or statements that will:       Print the first two digits and the  last...
5. Write a C++ statement or statements that will:       Print the first two digits and the  last two digits of any 4 digit number stored in an integer variable n.         For example, given int n = 5623, print 56    23. 6. Write  C++ statements that will align the following three lines as printed in two 20 character columns. Name                                                 Years President Abraham Lincoln                                 1860-1865 Thomas Jefferson                               1801-1809 7.  Write a C++ statement or statements that will Output if a string has a length greater than 10, equal...
C++ Change the program to take user input for first name and last name for five...
C++ Change the program to take user input for first name and last name for five employees. Add a loop to read the first name and last name. // EmployeeStatic.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <string> #include <iostream> #include <string> using namespace std; class Employee { public:    Employee(const std::string&, const std::string&); // constructor    ~Employee(); // destructor    std::string getFirstName() const; // return first name    std::string getLastName() const; // return...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT