How to convert this into a while loop

0 Ash Marz · July 6, 2015

#include 
int main()
{
int n, c, k;

printf("Enter number of rows\n");
scanf("%d",&n);

for ( c = 1 ; c  

Post a Reply

Replies

Oldest  Newest  Rating
0 K D · July 7, 2015
i will assume you want a while loop instead of a for loop am i right?  Move the initialize statement for c out side of loop and put the decrement or increment at the bottom of the loop block

Example:
c=1;
while(c < 5){
    ...
    c++;
}

You can also do this with a do while loop but depending on what you are doing you might want a conditional such as an if statement around the loop..
I Really Hope this helps :)...
  • 1

C

118,532 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator