problem in printing of stars

I cant figure out what is the problem. the program is to print this pattern
____*
___**
__***
_****
*****


The program runs but does not print above pattern,so plz help me


#include<iostream>
using namespace std;
int main(){
int i=1;int j=1;int size;int k=1;int y=1;
cout<<"enter the size"<<endl; //taking size
cin>>size;
int r=size;
while(size>=i){
while(i>=j){
while(r>k){
cout<<" "; //creating space
k++;
}
k=1;

cout<<"*"; //creating star
j++;
}
j=1;

cout<<endl;
r--;
i++;
}


return 0;
}
Last edited on
closed account (o3hC5Di1)
Hi there,

Welcome to the forums. Please wrap your code in [code][/code]-tags, it makes it more readable. Also, please describe your problem clearly and specifically. You mention that there is a problem with the program - what sort of problem? Does the program compile, if not, which errors do you get? If the program compiles, does it crash, again which errors do you get? If the program runs fine but it gives you unexpected output, please tell us which output you expect and which output you are getting.

All the best,
NwN
Topic archived. No new replies allowed.