Coding 3 basic programs for C++

timer Asked: Apr 3rd, 2017

Question Description

Nested Loops

Program 1:

The following program generates displays all two-letter .com internet domain names, 13 names per line.

#include <iostream>

using namespace std;

int main()


char letter1, letter2;

int count=0;

cout<<"***Two letter domain names**<< endl;


for(letter1='a'; letter1<='z';letter 1++)


for (letter 2'a';letter2<='z';letter2++)

cout <<letter1<<letter2<<".com\t"'count++;







1.Type in the above program, add your name and date, compile and run the program

2.How many times does the outer loop execute?

3.How many times does the inner loops execute?

4.Modify the program to include two-character .com names where the second character can be a letter or a number, as in


Program 2:

Write a program that graphically depicts an integer’s magnitude by using asterisk, creating a


Hint:The inner loop handles the printing of the asterisk and the outer loop handles exciting until zero is entered. Make sure you don’t accept negative numbers.

Sample run: Enter a positive integer (0 to quit): 5


Enter a positive integer (0 to quit): 8


Enter a positive integer (0 to quit):-5

Enter a positive integer (0 to quit):-10

Enter a positive integer (0 to quit): 15


Enter a positive integer (0 to quit): 0

Good Bye!

Submit a copy of the program

and sample output for at least 4-5numbers, including

invalid data.


Program 3:

Write a program to display an upside down right triangle. You should ask the user to provide you with the height.

Sample Run:Enter a number between 5 and 50: 10











Would you like to continue (Y/N)? N

Good bye!


Submit a copy of the program

and sample output for at least 2-3 numbers, including invalid data

This question has not been answered.

Create a free account to get help with this and any other question!

Brown University

1271 Tutors

California Institute of Technology

2131 Tutors

Carnegie Mellon University

982 Tutors

Columbia University

1256 Tutors

Dartmouth University

2113 Tutors

Emory University

2279 Tutors

Harvard University

599 Tutors

Massachusetts Institute of Technology

2319 Tutors

New York University

1645 Tutors

Notre Dam University

1911 Tutors

Oklahoma University

2122 Tutors

Pennsylvania State University

932 Tutors

Princeton University

1211 Tutors

Stanford University

983 Tutors

University of California

1282 Tutors

Oxford University

123 Tutors

Yale University

2325 Tutors