Question

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

The first letter A and the last letter O

Homework Answers

Answer #1

Source Code:

#include <bits/stdc++.h> 
using namespace std; 
  
void printInitials(string str)  
{ 
    int len = str.length(); 
  
    str.erase(0, str.find_first_not_of(' ')); 
    str.erase(str.find_last_not_of(' ') + 1); 
  
    string t = ""; 
    for (int i = 0; i < len; i++)  
    { 
        char ch = str[i]; 
  
        if (ch != ' ') 
  
            
            t = t + ch; 
  
        else
        { 
            cout << (char)toupper(t[0]) << ". "; 
            t = ""; 
        } 
    } 
  
    string temp = ""; 
   
    for (int j = 0; j < t.length(); j++)  
    { 
        if (j == 0) temp = temp + (char)toupper(t[0]); 
  
        else
            temp = temp + (char)tolower(t[j]); 
    } 
  
    cout << temp << endl; 
} 
int main()  
{ 
    string str = "Your Name"; 
    printInitials(str); 
} 
Let me know if you have any doubts or if you need anything to change. 

If you are satisfied with the solution, please leave a +ve feedback : ) Let me know for any help with any other questions.

Thank You!
===========================================================================
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
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 my name's Aya amro
Write a program that asks the user for the name of a file. The program should...
Write a program that asks the user for the name of a file. The program should display only the first five lines of the file’s contents. If the file contains less than five lines, it should display the file’s entire contents. by python using while loop
In C# using the Console App (.NET FRAMEWORK) Create and test a Windows Console application that...
In C# using the Console App (.NET FRAMEWORK) Create and test a Windows Console application that displays the following patterns separately, one after the other. You MUST use nested for loops to generate the patterns, like the example in the PowerPoint slides from this chapter. All asterisks (*) should be displayed by a single statement of the form Console.Write("*"); which causes the asterisks to display side by side. A statement of the form Console.WriteLine(); can be used to move to...
Write a program on C++ to calculate and print the factorial of a number using a...
Write a program on C++ to calculate and print the factorial of a number using a for loop. The factorial of a number is the product of all integers up to and including that number, so the factorial of 4 is 4*3*2*1= 24.
Draw a timing diagram for the first four letters of your last name, given the following...
Draw a timing diagram for the first four letters of your last name, given the following specifications about the RS232 serial communications channel:           Baud rate:     115,200 baud           Data length: 8 bits           Parity:           None           Stop bits:      1 The first three letters of your last name should include at least one upper case letter and one or two lower case letters (If your last name is 3 letters or less, use first name). Indicate the bit time for...
Write a code segment to print your name ten times on the screen using a while...
Write a code segment to print your name ten times on the screen using a while loop. Use one variable called count to act as a counter for the loop. Discuss how would you print your name 1000 times on the screen. NOTE: You can either type your code into the text box or upload a document to the discussion board by clicking the "attach" clip at the bottom left of the discussion box.
Write a program (C language) that will read the number of a month and will print...
Write a program (C language) that will read the number of a month and will print the number of days in the month. Ignore leap years. Use 28 days for February. Have the program runs in a continuous loop, allowing the user to enter a month number, see that number of days, and repeat. Use month number = 0 to exit the loop and the program. Program must meet the following criteria: 1.Your name and the name of the program...
By using Python code answer the following parts: A) Write a program to ask the user...
By using Python code answer the following parts: A) Write a program to ask the user to input their name and then output the type and length of the input. B) Write a program to output the last 11 letters of 'Introduction to Indiana'. C) Write a program to output the 3rd to the 11th letters of 'Introduction to Indiana'. D) Write a program to ask the user to input a float number and output the rounded value of it...
1. a)Write a program that displays the name and address of your college in C# b)Write...
1. a)Write a program that displays the name and address of your college in C# b)Write a program that prompts the user for his name and average monthly visa bill. The program displays his name and his annual visa bill. You must match the format exactly: Name: Justin Bieber Annual Visa Bill: $12,000.00 Hint: annual bill = monthly bill * 12 c)Write a program that prompts the user for a letter. The program prints the letter and the number equivalent....
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in...
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in Lab 2 to obtain a diameter value from the user and compute the volume of a sphere (we assumed that to be the shape of a balloon) in a new program, and implement the following restriction on the user’s input: the user should enter a value for the diameter which is at least 8 inches but not larger than 60 inches. Using an if-else...