Pages

Wednesday, September 14, 2016

Use of break statement in C program.



//To demonstrate use of break statement.

#include<stdio.h>
void main()
{
     int rollno, i;
     for(i=0; i<5; i++)
     {
    printf("Enter your number:");
           scanf("%d", &rollno);               
           if ( rollno == 10)
           {
                printf("Pay your fees.");
                break;
           }
        printf("%d is eligible...Give your exam.\n", rollno);
     }
     printf("Good bye");
}


Output of the Program:
Enter your number:1
1 is eligible...Give your exam.
Enter your number:2
2 is eligible...Give your exam.
Enter your number:10

Pay your fees. Good bye

No comments:

Post a Comment