This document contains 3 programming questions and code snippets. It asks about the output and function of a program that prints hash tags in a forward slash shape, uses while loops to print the shape, and uses a switch statement to print different names.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
20 views
CS 31 HW
This document contains 3 programming questions and code snippets. It asks about the output and function of a program that prints hash tags in a forward slash shape, uses while loops to print the shape, and uses a switch statement to print different names.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2
Question 1: Program Output endlendl grendel Question 2: Program Function This program prints out hash tags in the
shape of a forward slash. Question 3: While Loops
#include <iostream> using namespace std; int main() { int len; cout << "Enter a number: "; cin >> len; int i int j w ile { j w { = 0; = 0; (i < len) = i ! "; ile (j < len) cout << " "; j!!; # cout << "#" << endl; i!!;
# #
Question : !o While Loops
#include <iostream> using namespace std; int main() { int len; cout << "Enter a number: "; cin >> len; int i = 0; int j = 0; do { i$ (len % i <= 0) { brea&; # else { j = i ! "; do { i$ (len % i <= ") { brea&; # else { cout << " "; # j!!; # w ile (j < len); cout << "#" << endl; i!!; # # w ile (i < len); #
Question ": #wtich #tatements
switc { 'ear case "()0: cout case "()(: case /000: case /0"1: cout case /00( cout de$ault: cout # << *+obert ,e -iro.;