Unconditional Statements in C Programming Language

Unconditional Statements in C Programming Language



Unconditional Statements:
UnConditional Statements allows you to direct the program's flow to another part of your program without evaluating conditions.
These are classified into following types.

1.continue
2.break

continue
'continue' statement is used to continue the loop( It skip the one iteration if the condition is true).

Syntax:
if(condition)
{
    continue;
}


Display Even Numbers Unsing Continue Statement

#include <stdio.h>
int main() {
    int x;
    for(x=1;x<=30;x++)
    {
        if(x%2!=0)
        {
            continue;
        }
        printf("\n%d",x);
    }
    return 0;
}                                         

Output:

2
4
6
8
10
12
14
16
18
20
22
24
26
28
30



Break
'break' statement is used to break the loop.
Syntax:
if(condition)
{
    break;
}


Break the loop which number divisible 2 and 3

#include <stdio.h>
int main() {
    int x;
    for(x=1;x<=30;x++)
    {
        if(x%2==0 &&x%3==0)
        {
            break;
        }
        printf("\n%d",x);
    }
    return 0;
}                                         

Output:

1
2
3
4
5




More Programs

Write a C-program to print 1 to n values using while loop

Write a C-program to print even numbers using while loop

Write a C-program to print even number or odd number based on the n value using while loop

Write a C-program to print even number or odd number based on the n value using single while loop

Write a C-program to count the number of divisible numbers in a given range(1-100) using while loop

Write a C-program to print factorial number using while loop