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

my name's Aya amro

Homework Answers

Answer #1

SOLUTION:

The following code will print first letter of your first and last name beside each other:

#include <iostream> 
using namespace std; 
int main() 
{ 
    int n; // variable declaration
    cout<<"Enter no of lines (min 4): "; 
    cin>>n; // Get user input for number of lines
    for (int i = 0; i < n; i++) { 
        int letter=0;
        // In your case both letter are A, so reusing logic to print twice
        while(letter<2){
        // No of lines
        for(int j=0;j<=n/2;j++){
            // Condition for vertical, first and middle lines respectively
            if ((j==0||j==n/2)&&i!=0||i==0&&j!=0&&j!=n/2||i==n/2){ 
                cout<<"*"; 
            }
            else{
                cout<<" "; 
            }
        }
        cout<<"     "; // Adjust this for space between two letters
        letter++;
        }
        cout<<endl; 
    } 
    return 0; 
} 

OUTPUT:

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 The first letter A and the last letter O
Assignment 2 Create a Java program called UserNames that reads the user's first and last name...
Assignment 2 Create a Java program called UserNames that reads the user's first and last name (separately), then prints a string composed of the first 4 letters of the user's last name, followed by the first letter of the user's first name, followed by a random number in the range of 10 to 99 (inclusive). You can assume the first name is at least one letter long and the last name is at least 4 letters. After doing this once,...
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 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 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.
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....
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...
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.
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT