0
what is the mistake in this code?
#include <iostream> using namespace std; int main() { int rows; cout<<"enter no. of rows required to print pyramid"; cin>>rows; for(int a=1; a<=rows; a++) { for(int b=a; b<rows; b++) { cout<<" "; } for(int c=1; c<=(2a-1); c++) { cout<<"*"; } cout<<endl; } return 0; }
2 Réponses
+ 6
"2a" doesn't mean 2 multiplied by a. To the compiler, it's simply a bad identifier. Write "2*a" instead.
0
thanks Hatsy Rei