Pyramid of Stars [closed]

This is in no-way pretty, but it should work

#include <stdio.h>

void main(){
    int size = 3,i;      //you can't just pass a value into main like that so I've initialised size here
    while (size){        //loop controlling line output
        i = 0;
        while (i++<size){//loop controlling * output within line
            putchar('*');//output a *
        }
        putchar('\n');   //output a newline (go to next line)
        size--;
    }
}

If you check the syntax of for loops, you should be able to translate this to use them pretty easily (I’m nice but I’m still not going to give you your entire assignment on a plate).

Leave a Comment