Write about Additional Features of For Loop?

The for loop in C has several capabilities that are not found in other loop constructs.

1.More than one variable can be initialized at a time in the for statement.
Ex:– for(p=1, n=0; n<10;++n )

2. The increment section may also have more than one part.
Ex:–for(n=1, m=50; n<=m;n=n+1, m =m–1)

The multiple arguments in initialization section & in the increment section are separated by commas.

3. The test–condition may have any compound relation & the testing need not be limited only to the loop control variable.
Ex:–for(i=1; i<10&&sum<100;i++)

4.It is also possible to use expressions in the assignment statements of initialization & increment sections.
Ex:– for(x=(m+n)/2; x>0;x=x/2)

5. Another unique aspect of for loop is that one or more sections can be omitted, if necessary.
Ex:–m=5;
For(;m!=100;)
{
printf(“%d\n”,m);
m=m+5;
}

6. We can set uptime delay loops using the null statement as follows.
Ex:– for (i=1000;j>0;j=j–1);

This loop is executed 1000 times without producing any output. It simply causes a time delay.

Related

Write about Constant Pointers in C

Constant Pointers A constant pointer is a pointer that cannot change the address its holding. In other words, we can say that once a constant pointer points to a variable then it cannot point to an...

What is an Array? Explain about One-Dimensional Arrays?

The fundamental data types can store only one value at any given time. To process large amounts of data, c supports a derived data type known as Array. An array can be use...

What is a Function ? Explain Different types of Functions?

Functions are a self contained block of code that performs a particular false. A function can take some data from the main program, and returns a value. The large program...

Post a Comment

emo-but-icon
:noprob:
:smile:
:shy:
:trope:
:sneered:
:happy:
:escort:
:rapt:
:love:
:heart:
:angry:
:hate:
:sad:
:sigh:
:disappointed:
:cry:
:fear:
:surprise:
:unbelieve:
:shit:
:like:
:dislike:
:clap:
:cuff:
:fist:
:ok:
:file:
:link:
:place:
:contact:

item