Atlas - main.c

Home / lab / c / weird_loops Lines: 13 | Size: 1154 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)]
[FILE BEGIN]
1/* SPDX-License-Identifier: GPL-3.0 2 * weird_loops 3 * 4 * main.c 5 * 6 * Looping in a weird way 7 * 8 * COPYRIGHT NOTICE 9 * Copyright (C) 2024-2025 0x4248 and contributors 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the license is not changed. 12 * 13 * This software is free and open source. Licensed under the GNU general 14 * public license version 3.0 as published by the Free Software Foundation. 15 */ 16 17#include <stdio.h> 18#include <stdlib.h> 19 20int jumps(){ 21 int i = 0; 22loop: 23 if (i < 10) { 24 printf("i = %d\n", i); 25 i++; 26 goto loop; 27 } 28 return 0; 29} 30 31int while_loop() { 32 int i = 0; 33 while (i < 10) { 34 printf("i = %d\n", i); 35 i++; 36 } 37 return 0; 38} 39 40int normal_loop() { 41 for (int i = 0; i < 10; i++) { 42 printf("i = %d\n", i); 43 } 44 return 0; 45} 46 47int do_while_loop() { 48 int i = 0; 49 do { 50 printf("i = %d\n", i); 51 i++; 52 } while (i < 10); 53 return 0; 54} 55 56int main() { 57 58 printf("Normal loop\n"); 59 normal_loop(); 60 printf("\n"); 61 62 printf("While loop\n"); 63 while_loop(); 64 printf("\n"); 65 66 printf("Do while loop\n"); 67 do_while_loop(); 68 printf("\n"); 69 70 printf("Jump loop\n"); 71 jumps(); 72 printf("\n"); 73}
[FILE END]
(C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.