C++ program that outputs a triangle pattern using two nested do...while loops.The number of loops should only be two.
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int n;
int R;
char ch;
//do while loop
do// do
{
cout << "Enter an integer" << endl;
cin >> n;
cout << "Enter symbol" << endl;
cin >> ch;
for(R=0;R<n;R++)
{
for (int A=0; A<=R;A++)
{
cout<<ch;
}
for (int len=n;len>R+1;len--)
cout<<" ";
cout<<endl;
}
cin.ignore();
cin.ignore();
}
while(cin);//while
return 0;
}
#include <iostream>
using namespace std;
int main()
{
cout<<"Hello World";
return 0;
}
Comments
Leave a comment