Define the syntax of for loop, Programming Languages

Assignment Help:

Define the Syntax of FOR Loop?

The universal form of this statement is

for(initialization;condition;increment/decrement)

            {

statements;

            }

The Initialization refers to the assignment of control variable and the control variable is any variable that is used in the for loop. The condition is a logical or relational expression for testing the value of control variable. If the condition is true, then the body of the loop will get executed, otherwise the control will come to the statement that immediately follows the loop. formerly the loop gets executed the control is transferred back to the statement after evaluating the last statement in the loop. The control variable is then decremented or incremented and the new value of the variable is tested to see whether the condition is satisfied. Every expression should be seperated using semicolon.

For illustration

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

{

sum=sum+i;

}

The expression 'for(;;) is as well valid, but this loop will execute infinite times. A Nested for loops are allowed in C programs.

For instance

for(i=0;i

{

for(j=0;j<=n;j++)

{

sum=sum+i;

}

}

This can as well be written as

for(i=0, j=0;i

{

sum=sum+i;

}


Related Discussions:- Define the syntax of for loop

Develop a context diagram and use case diagram, Develop (i) a context diagr...

Develop (i) a context diagram and (ii) a use case diagram to model the following functionalities of NetFlix. Netflix is an online video/DVD renting company. A customer desiring

Assembly language, I need help with having a user input a year, and my prog...

I need help with having a user input a year, and my program to spit out what day of the week Christmas is on.... any helping hands on this?

Cobol, i have 4 variables in my linkage section of PIC 9(3) ..while submitt...

i have 4 variables in my linkage section of PIC 9(3) ..while submitting i m passing parameter value i.e. numeic to them but its taking space for 2 varaible and for two its taking c

C-program, about how to create the program in c

about how to create the program in c

Program for adding a course in the website of a university, 1. You are work...

1. You are working as a designer for a university that offers a program in Computer Science. One of the tracts is computer security. One of your colleagues has recommended adding a

Define the procedures cons, Show that we can represent pairs of nonnegative...

Show that we can represent pairs of nonnegative integers using only numbers and arithmetic operations if we represent the pair a and b as the integer that is the product 2 a 3 b .

How to write a kernel module, Overview You will write a loadable kernel...

Overview You will write a loadable kernel module. If you have an idea which you can convince me is a good idea that can not be done as a module, but only via direct modificatio

Program for nuclear reactor - embedded systems, Implement the "Nuclear Reac...

Implement the "Nuclear Reactor" example using the following:  An ISR triggered by a button press  A task to update the temperatures  A semaphore to communicate between the ISR and

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd