Computer Science, asked by birukishan22gmailcom, 1 year ago

will the for loop execute without initialization? Explain with examples.


MonsieurBrainly: what programming language is it

Answers

Answered by Anonymous
14
A loop is used for executing a block of statements repeatedly until a given condition returns false.

C For loop

This is one of the most frequently used loop in C programming.

Syntax of for loop:
for (initialization; condition test; increment or decrement)
{ //Statements to be executed repeatedly }

Step 1: First initialization happens and the counter variable gets initialized.

Step 2: In the second step the condition is checked, where the counter variable is tested for the given condition, if the condition returns true then the C statements inside the body of for loop gets executed, if the condition returns false then the for loop gets terminated and the control comes out of the loop.

Step 3: After successful execution of statements inside the body of loop, the counter variable is incremented or decremented, depending on the operation (++ or –).

Example of For loop

#include <stdio.h>
int main()
{
int i;
for (i=1; i<=3; i++)
{
printf("%d\n", i);
}
return 0;
}

HOPE THIS ANSWER WILL HELP U.....

birukishan22gmailcom: yeah i got it as the best answer. Are you a boy or a girl?
Anonymous: girl
birukishan22gmailcom: Can i ask your name?
birukishan22gmailcom: Can i please know your name?
Anonymous: hey meet me in inbox...
birukishan22gmailcom: Where?!!!
Anonymous: message kiya h mene just go in message box....
birukishan22gmailcom: I didn't understand!!!
Anonymous: open my profile and message me
birukishan22gmailcom: Didi go to message box and see my messages
Similar questions