Tuesday, July 28, 2009

What is the code for C programming language?

that keeps the program looping until a -1 or some other number?

What is the code for C programming language?
I think what you're looking for is a while loop. So you'd need something like this.





int someNumber = 5;





while(someNumber != -1){





printf("%d\n", someNumber);


someNumber = someNumber - 1;





}





The above code should print:


5


4


3


2


1


0
Reply:until a - 1?


do you mean until a == -1 ?





the while loop suggested above will work, but if you're iterating over a, you probably want a for loop instead:





for (int a = 7; a %26gt; -1; --a)


{


/* do something here */


}

purple flowers

No comments:

Post a Comment