Coding 3 basic programs for C programming homework help – www.savvyessaywriters.net
Coding 3 basic programs for C programming homework help – www.savvyessaywriters.net
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;
Cout<<“**************<endl;
for(letter1=’a’; letter1<=’z’;letter 1++)
{
for (letter 2’a’;letter2<=’z’;letter2++)
cout <<letter1<<letter2<<“.comt”‘count++;
if(count%13==0)
cout<<endl;
}
count<<endl;
}
}
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 a2.com
——————————-
Program 2:
Write a program that graphically depicts an integer’s magnitude by using asterisk, creating a
histogram.
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
Savvy Essay Writers
