Computer Science, asked by RiyaWani, 1 year ago

how to convert one loop to another loop plz explain

Answers

Answered by p1998
2
to convert one loop to another loop

Firstly I think that you are aware about the basic usage of loops i.e, repeating a task no matter what ever may be the task.

Now coming to your question

/* Let's say the task to be executed is printing god for 6 times in c programming*/

i=0;. // This is the initialisation of the loop

while (i<6) // condition

{

printf(“God”); // task

i++; / *incrementing the loop after the execution of task*/

}

A for loop template is as follows

for(initialisation; condition; increment/decrement)

{

Task;

}

Template reflects that inside a for only the task will be there nothing more than that so everything like condition and incrementing will be defined while writing the loop

for the same problem the execution using for loop is as follows

for(i=0;i<6;i++)

{

printf(“God”);

}

p1998: if it helped you mark it as brainliest
RiyaWani: ya I will when I will get notification
p1998: ok
Similar questions