break and continue statement

//program with continue
#include<stdio.h>
#include<conio.h>
int main()
{
    int i;
    for (i=1;i<10;i++)
    {
        if(i==5)
        {
            continue;
        }
         printf("%d\t",i);
    }
    getch();
}
output:
here 5 is loss due to continue,it does not print 5 because it goes to increase the value of i by i++








//program with break
#include<stdio.h>
#include<conio.h>
int main()
{
    int i;
    for (i=1;i<10;i++)
    {
        if(i==5)
        {
            break;
        }
         printf("%d\t",i);
    }
    getch();
}
output:
here after finding the 5,for loop is end.


No comments

Powered by Blogger.