Thursday, July 9, 2009

C Programming?

how can get like this out put in c?


*


***


*


***


*****


*


***


*****


*******


|


---+---

C Programming?
use the printf(" place what you want in here with \n to start a new line")....That is if i remember well...check if println is the actual what is used to print on the screen as it has been a while since i programmed in C
Reply:top two answers are correct... he even wrote it for you.... :)
Reply:Uhhh... yeah..... you could just do a bunch of 'print' statements, but something tells me that's not what you are looking for. So, I will give you some idea of how I would do it. It looks like the pattern is odd numbers of stars, incrementing with the next odd number each time. So, basically, it would be a loop within a loop : the outside loop would be the 'main' counting loop that would start at 1, and go up by increments of 2 (1, 3, 5, 7). The inside loop would be dependent on the outside loop, and would count up from 1 to the value of the outside loop, also by 2's, printing that number of stars. Something like this for outside loop :





for(count=1; count%26lt;9; count=count+2)





...and for the inside loop





for(count2=1; count2%26lt;=count1; count2=count2+2)





... then you would print the stars inside this loop. You might have to play with this a little, but this is along the lines of what needs to be done. Good luck.
Reply:#include %26lt;stdio.h%26gt;





int main()


{


printf("*\n");


printf("***\n");


printf("*\n");


printf("***\n");


printf("*****\n");


printf("*\n");


printf("***\n");


printf("*****\n");


printf("*******\n");


printf("|\n");


printf("---+---\n");





return 0;


}


No comments:

Post a Comment