Skip to main content

What is Break and Continue statement in Programming? (Answer)

What is Break and Continue statement in Programming? (Answer)

Both Break Statement and Continue Statement are important in all programming languages. Here is the definition of both statements with examples...

Break Statement

The break statement is used to exit from a while, for, do, or switch structure. It can be only used inside the body of a for, while, do statement. This statement is used to terminate the control from the switch case as well in the loop. When the break statement is encountered it terminates the execution of the entire loop or switch case. It doesn't bypass the current loop through it transfers the control out of the loop.
Example:

for (i = 1; i<=5; i++)
{
if(i==4)
    break;
Printf ("%d", i);
}

Continue Statement

The continue statement is used to bypass the execution of the further statements. When the continued statement is encountered it bypasses a single pass of the loop. It is used to bypass the current pass through a loop. The loop doesn't terminate when continue encountered.
Example:

for (i=1; i<=5; i++)
{
if (i==3)
   continue;
Printf("%d", i);
}

The break statement terminates the loop if it meets the condition.

Continue Statement skips the remaining statement.


Comments

Popular posts from this blog

What is Kite Flying? - Definition

Kite-Flying is a popular game. It is played in the autumn season. This season is fit for kite-flying, for it is neither much cold nor much hot. The harvesting season is over, and people have plenty of time at their disposal. Boys are very fond of kite-flying. Even grow-up men take part in it. The kite-flying season lasts two months. The kite is made of a square piece of paper. The paper is white or colored. there are two sticks pasted on this paper. One stick is straight and the other is curved. The straight stick is placed diagonally. The curved stick is placed nearly at the top of the straight stick, its ends touching two corners of the paper. The straight stick is tied with a piece of thread at two points just below its ends. This thread is joined to a long thread wound on a reel. The kite-flier holds the reel with his hands. He needs a helper for flying the kite. The helper catches the kite with his hand and goes to a long distance. He throws the kite up, and the flier pulls

What is LAN and WAN Networks? - Definition

LAN and WAN are the two types of computer network on the basis of geographical area coverage. Both are different from each other. Here is the definition of both networks. LAN (Local Area Network) The interconnection within room or building is known as LAN (Local Area Network). The data transmission rate is faster than WAN. Most of the LAN is built with relatively cheap hard drives like Ethernet cables, network adapters, and hubs. LAN has higher security to resources of the network. It is more easy to manage and operate. It can operate at a speed of 100mbps. There is lack of backup compares to WAN in LAN. It is only limited for short distance. The network structures of LAN is in Homogenous form. WAN (Wide Area Networking) The interconnection within a country or between neighbor countries and within a continent is known as WAN (Wide Area Networking). The data transmission rate is slower than the LAN. WAN use much expensive software than LAN. It helps to send data/information

What do you mean by Bounded media and Unbounded media? (Definition)

Bounded and unbounded media are the transmission media which is used to transfer data from one destination to another through its means. Bounded Media The transmission media which uses to transmit the signal/data/information from one to another is known as bounded media. The data transmit rate is faster than the unbounded media. Bounded media is used to transmit data/information in short distance. It uses twisted pair cable, coaxial cable, and fiber optic cable as transmission media. All the computer and devices are physically connected in bounded media. Unbounded media The transmission media which uses wireless to transmit data/information/signal from one to another is known as unbounded media. The data transmit rate is slower than the bounded media. It is used for transmitting the data/signal/information for long-distance. It uses radio wave/microwave/communication satellite as transmission media. All the computer and devices aren't physically connected. Bounded m