C Coding
Basic Examples
Hello World
#include <stdio.h> // Inclusion for standard Input/Output library
main()
{
printf("Hello Hackers\n"); //print 'Hello Hackers' with a new line (\n).
return 0; // Linux returns 0 typically for a successful run, Windows likes the opposite
}For Loops (with a bit of int concatenation)
#include <stdio.h> // Standard input output
int main() {
int beers; // Initialisation of int for beers
printf("A fitting example for hackers.\n\n");
for (beers = 99; beers > 0; beers-- ) // This will loop until beers = 0
{
printf("Bottles of beer on the wall, %d Bottles of beer\n", beers);
printf("Take one down and pass it around, %d bottles of beer on the wall.\n\n", beers);
}
printf("No more bottles of beer on the wall, no more bottles of beer.\n");
printf("Go to the store and buy some more, 99 bottles of beer on the wall.\n");
printf("\nAnd conditional loops are just that easy");
return 0;
}While Loops (with the rand function)
rand function)File Creation
Last updated
Was this helpful?