#include <iostream>
using namespace std;
void drawTriangle(int w) {}
int main() {}
Complete the program so that it produces a centered, isosceles triangle of a user-specified width.
For example:
Enter a width: 5
Result:
***** *** *
#include <iostream>
using namespace std;
void drawTriangle(int w) {
int n = 5, s = 0;
for(int i = 0;n>0;i++){
for(int k = 0;k<s;k++){
cout<<" ";
}
for(int j = 0;j<n;j++){
cout<<"*";
}
cout<<endl;
n -= 2;
s += 1;
}
}
int main() {
int w;
cout<<"Enter a width: ";
cin>>w;
drawTriangle(w);
return 0;
}

#include <iostream> using namespace std; void drawTriangle(int w) {} int main() {} Complete the program so...
#include <iostream> using namespace std; void drawTriangle(int x) {} int main() {} Complete the program so that it produces a right-angle triangle of a user-specified height. For example: Enter a height for the triangle: 5 Result: * ** *** **** *****
#include <iostream> using namespace std; void drawRect(int h, int w) {} int main() {} Write a program that produces h x w rectangles comprised of alternating columns of 1's and 0's (where h and w all user-specified). For example: Enter the desired dimensions for a rectangle: 6 4 Result: 1010 1010 1010 1010 1010 1010
#include <iostream> using namespace std; int main() {} Write a program that produces a line comprised of n alternating a's and b's, where n is user-specified. For example, the console content following a run of the completed program with an input of "5" is as follows: Enter a number: 5 A line of length 5: ababa
#include <iostream> using namespace std; int main() { } Write a program that, given a user-specified integer, prints out the next 10 integers (in increasing order; each on its own line). For example, given an input of 3, the console content following a run of the completed program will look as follows: Enter a number: 3 4 5 6 7 8 9 10 11 12 13
#include <iostream> using namespace std; int main () { } Write a program that converts a numeric score (provided by the user) into a letter grade (A, B, C, D, or F). The point-to-letter conversion rules are as follows: score >= 90: A score >= 80 (but less than 90): B score >= 70 (but less than 80): C score >= 60 (but less than 70): D otherwise: F The completed program should produce console content as follows: Enter your...
Write the missing statements for the following program. #include <iostream> using namespace std; int main(void) { int Num1; cout << "Enter 2 numbers: "; cin >> Num2; if (Num1 < Num2) cout << "Smallest number is " << Num1; else cout << "Smallest number is " << Num2; return 0; }
#include <iostream> using namespace std; int main() { } Write a program that solicits a user-specified amount of numbers and their values, and then computes the average value, as well as their parity (how many even versus odd). Below is the console content of an example run of the completed program. How many numbers would you like to store? 8 Enter the 8 numbers: 0 7 3 1 5 6 2 3 Average value: 3.125 Parities: 3 even, 5 odd
Consider the following C++ program: #include <iostream> using namespace std; void f1(int); void f2(int); void f3(int); int main() { f1(10); return 0; } void f1(int n) { f2(n + 5); } void f2(int n) { f3(n - 2); } void f3(int n) { cout << n << endl; // LINE 1 } Just before the program statement marked with the comment "LINE 1" is executed, how many stack frames will be on the program call stack?
C++ question #include <iostream> using namespace std; void printReverse(int); int main() { int number = 12345; cout << "Original : " << number << endl; cout << "Reversed : "; printReverse(number); } void printReverse(int x) { if (x == 0) return; cout << x % 10; printReverse(x /= 10); } Modify the above recursive program to output the number in the same order. Note that the program still should break up the number and then output it in the...
Write following program using Switch statement. #include <iostream> using namespace std; int main() int number; cout << "Enter an integer cin >> number; if (number > B) cout << You entered a positive integer: " << number << endl; else if (number (8) cout<<"You entered a negative integer: " << number << endl; cout << "You entered e." << endl; cout << "This line is always printed." return 0;