The easiest way is probably
#include <iostream>
#include<string>
using namespace std;
int main (){
int a=2;
while(a<=6){
cout<< a << std::string((a/2),'*') <<endl;
// ^^^^^^^^^^^^^^^^^^^^^^
a+=2;
}
return 0;
}
0
solved how to print char in multiple times in c++