-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path16th_program.c
More file actions
31 lines (29 loc) · 829 Bytes
/
Copy path16th_program.c
File metadata and controls
31 lines (29 loc) · 829 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Write a program that shows the use of break and continue statement.
#include<stdio.h>
int main()
{
int num,sum=0,i;
printf(" Enter below from these options. \n Enter a postive integer to find their sum \n Enter zero to skip \n Enter negative integer to exit \n\n");
// I have intentionally not update the value of i, because condition to exit is already set.
while(i<10)
{
printf("Enter a number : ");
scanf("%d",&num);
if(num>=1)
{
sum+=num;
}
else if(num==0)
{
sum+=num;
continue;
}
else if(num<0)
{
printf("You exited \n");
break;
}
}
printf("Sum of positive numbers you entered =%d \n",sum);
return 0;
}