0% found this document useful (0 votes)
36 views9 pages

Programming Loops: While & For Examples

The document describes hands-on activities using while loops, for loops, break, and continue in C programming. It includes the C code used and the output generated for each activity.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views9 pages

Programming Loops: While & For Examples

The document describes hands-on activities using while loops, for loops, break, and continue in C programming. It includes the C code used and the output generated for each activity.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

DELA CRUZ, RIA DIVINE T.

2021-10772
EIT 0329.1-1 (COMPUTER FUNDAMENTALS AND PROGRAMMING)

Hands-On Activity 5: While Loop, For Loop, Break and Continue (While Loop/For
Loop)

• PROGRAMMING CODES (Print Screen)


• OUTPUT (PRINT SCREEN)
• PROGRAMMING CODES
#include <stdio.h>

int main() {

// While Loop Programming

printf("While Loop Programming\n");

int z = 10;

while (z < 50){

printf("%d\n", z);

z += 5;

// For Loop Programming

printf("For Loop Programming\n");

int r;

for (r = 7; r <= 40; r += 4){

printf("%d\n", r);

// Break Programming, While Loop

printf("Break Programming (While Loop)\n");

int k = 3;

while (k < 21){

k += 3;

if (k == 15){

break;

printf("%d\n", k);
}

// Break Programming, For Loop

printf("Break Programming (For Loop)\n");

int y;

for (y = 10; y < 20; y++ ){

if (y==18){

break;

printf("%d\n", y);

// Continue Programming, While Loop

printf("Continue Programming (While Loop)\n");

int b = 5;

while (b <= 45){

b += 5;

if (b == 20){

continue;

printf("%d\n", b);

// Continue Programming, For Loop

printf("Continue Programming (For Loop)\n");

int a;

for (a = 43; a <= 78; a += 3 ){

if (a==52){

continue;
}

printf("%d\n", a);

return 0;

• OUTPUT
While Loop Programming

10

15

20

25

30

35

40

45

For Loop Programming

11

15

19

23

27

31

35

39

Break Programming (While Loop)

12
Break Programming (For Loop)

10

11

12

13

14

15

16

17

Continue Programming (While Loop)

10

15

25

30

35

40

45

50

Continue Programming (For Loop)

43

46

49

55

58

61

64

67

70

73

76

You might also like