Skip to main content

Explain continue and break statement with program example



Answer: 

Continue Statement:
The continue statement skips some statements inside the loop. The continue statement is used with decision making statement such as if...else.



General of continue Statement:
continue;

continue statement work:





Program:
#include<stdio.h>
#include<conio.h>
void main () {
   clrscr();
   int i;
   for(i=10;i<20;i++) {

      if(i==15)
             continue;
   printf("value of: %d\n",i);
   }
   getch();
}

Simple Output:
value of: 10
value of: 11
value of: 12
value of: 13
value of: 14
value of: 16
value of: 17
value of: 18
value of: 19


Break Statement:
The break statement terminates the loop immediately when it is encountered. The break statement is used with decision making statement such as if...else.

General of break statement:
            break;

 

Break statement works:




Program:
#include<stdio.h>
#include<conio.h>
void main() {
   clrscr();
   int i;
   for(i=10;i<20;i++) {
      if(i>15) {
             break;
      }
                        printf("value of: %d\n",i);
   }
   getch();
}

Simple Output:
value of: 10
value of: 11
value of: 12
value of: 13
value of: 14

value of: 15

Popular posts from this blog

Draw the basic organization of computer

Answer:                 The basic organization of computer__ Input Unit: ·          It accepts (or reads) instructions and data from outside. ·          It converts these instructions and data in computer acceptable form ·          It supplies the converted instructions and data to the computer system for further processing. Central Processing Unit (CPU): Control Unit: Control unit of a computer system manages and coordinates the operations of all other components of the computer system. Arithmetic Logic Unit(ALU): Arithmetic logic unit of a computer system is the place, where the actual executions of instruction, takes place during processing operation. Storage Unit: Primary Memory: It is volatile ( loses data on power dissipation). It is used to hold running program instruction, data, intermediate results, and results of ongoing processing of jobs. Secondary Memory: It i

Describe the four basic data types. How could we extend the range of values they represent?

Answer: The basic four data types are: Data Type Integer Type Character Type Floating Point Type Void Type signed int short int long int unsigned unsigned int unsigned short int unsigned long int char signed char unsigned char float double long double