I have successfully created a star pyramid using the below code, but i wanted to know if there is any other method by which i can do it using less loops or variables ??
OR maybe how would you do the star pyramid yourself ?
printf("Enter the height of pyramid : ");
I would add the needed return 0 to the end of main(), and replace getch() with the standard getchar(), unless you know it's only going to be used on compilers with conio.h (like Turbo C), which support getch().
I prefer the k++ idiom, instead of k+=1, but that's not important.
You've correctly identified the parts to the problem: the height, the preliminary spaces on each row, and the printing of the asterisks and newline.
Thanks for the suggestions :)