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
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.
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 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.
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...
python program on sonnets to Count the occurrences of each letter in the text.,. Print the...
python program on sonnets to Count the occurrences of each letter in the text.,. Print the number of one-letter, two-letter, three-letter words and so on. and Print the number of occurrences of each different word in the text using  the text from the sonnets.txt file and apply these three metrics
Write code in JAVA Write a program that will output a right triangle based on user...
Write code in JAVA Write a program that will output a right triangle based on user specified input height (int) and specified input symbol (char).The first line will have one user-specified character, such as % or *. Each subsequent line will have one additional user-specified character until the number in the triangle's base reaches specified input height. Output a space after each user-specified character, including after the line's last user-specified character. Hint: Use a nested for loop. Ex:If the input...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT