Senin, 17 November 2025

ex090.c do{} while() if() break

/* 0909.c */
#include <stdio.h>

int main()
{
    int count;

    count=0;
    while(1) /* selalu benar */
    {
        printf("%d, ", count);
        count=count+1;
        if(count>20)
            break; /* buat exit loop */
    }
    putchar('\n');
    return(0);
}

output:
 
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,

Process returned 0 (0x0)   execution time : 0.011 s
Press any key to continue.

Contoh penggunaan looping do{} while() if() break;

Tidak ada komentar:

Posting Komentar