#include<iostream> #include<string> #include<iomanip> using namespace std; int m
ID: 3769538 • Letter: #
Question
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
int main()
{
for (int c=1;c<=2;c++)
for(int b=1;b<=10;b++)
{
for(int a=1;a<=b;a++)
cout << "*";
cout << endl;
}
system("pause");
return 0;
}
I need three functions in the above program, at least 2 of the functions must return something to main.
It is C++ Class. Foundations of Computer Programming I
We use Visual Microsoft Studio.
I really the three functions ASAP! Thank you so much!
Explanation / Answer
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
string nstars(int n) {
char str[n];
for(int a=1;a<=n;a++)
str[a-1]='*';
str[n]='';
return str;
}
char newLine() {
return ' ';
}
void pyramid() {
for(int b=1;b<=10;b++)
{
cout<<nstars(b);
cout<<newLine();
}
}
int main()
{
for (int c=1;c<=2;c++)
pyramid();
system("pause");
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.