C program using break & continue.

 

01 #include<stdio.h>
02
03 int main()
04 {
05 int num;
06
07 while(1) //always true
08 {
09 printf("nnEnter a Number ( < = 100) to find its Square .");
10 printf("nPress 0 To Exit. : ");
11 scanf("%d",&num);
12 if(num==0)
13 {
14 printf("nProgram End. Thank You");
15 break;
16 }
17 else if(num>100)
18 {
19 printf("nYou Enter number greater than 100 : Try again");
20 continue;
21 }
22
23 printf("nSquare of %d is %d",num,(num*num));
24
25 }
26 return 0;
27 }
 
 
OUTPUT :

Enter a Number ( < = 100) to find its Square .
Press 0 To Exit. : 3

Square of 3 is 9

Enter a Number ( < = 100) to find its Square .
Press 0 To Exit. : 5

Square of 5 is 25

Enter a Number ( < = 100) to find its Square .
Press 0 To Exit. : 0

Program End. Thank You

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.