C Programming from 0 to 1

A guide to create the simplest programs using C programming

while (hasCoffee()) { code(); }

C programming is not difficult to learn. However, the initial slope is always boring and difficult to claim. For that, I create this guide to get you up and run.

GCC, (the GNU Compiler Collection)

We use Mingw-w64, the GCC for Windows 64 & 32 bits for our C compiler. You can go to https://sourceforge.net/projects/mingw-w64/ and download the right toolchains.

Or download from one of these links.

  • 32-bit (i686–7.2.0-release-posix-dwarf-rt_v5-rev1.7z)
  • 64-bit (x86_64–7.2.0-release-posix-seh-rt_v5-rev1.7z)

Tools

Command Line Tools

  • Command Line Prompt (Windows) / PowerShell (Windows)
  • Terminal (Linux/Mac)

IDEs

Editors

Installation and Run

I create videos illustrating how to install and run a simple C program.

Install C Compiler, MinGW64
Run “Hello World” using C Programming
Compile C sourcecode using Visual Studio Code
Eclipse and Xcode are next!

Hello World!

  1. Add Standard Input/Output Library header at the beginning of your source code. This is required, so that later you can use theprintf function.
#include <stdio.h>

2. Add the main function, it is the starting point of every C program.

#include <stdio.h>
int main() {
}

3. Add the return/ending of the function inside the main function. Don’t forget to indent 2 spaces so that we can see it belongs to the block of the main function.

#include <stdio.h>
int main() {
return 0;
}

4. Add a printf function above the return statement, to output a string to the console (the black screen).

#include <stdio.h>
int main() {
printf("Hello World");
return 0;
}

5. Add a comment above the printf() statement. The comment is ignored by the compiler. This means you can write anything there.

#include <stdio.h>
int main() {
// output "Hello World" to the console
printf("Hello World");

return 0;
}

The `printf` Exercises

This is the complete Hello World program. It does one thing, output “Hello World” to the console.

#include <stdio.h>
int main() {
printf("Hello World");
return 0;
}

1/ Write a program to output,

Hello C Programming!

2/ Write a program to output,

There is a will, there is a way.
As long as you have a strong commitment.

3/ Write a program to output a list of fruits.

We have 5 different fruits:
- Apple
- Banana
- Coconut
- Orange
- Mango

4/ Write a program to output,

When you meet your friends, you say "Hello"!
When you meet 'Hello', what did you say?

5/ Write a program to output,

*
* *
* * *
* * * *

6/ Write a program to output,

(\__/)     o---o     /\_/\      (o)_(o)
(=`.`) (`(Y)´) (=`%´=) (=`x´=)
(_(")(") c(")_(") (")_(")_/ \_(")(")

8/. Write a program to output,

        1
1 2 3
1 2 3 4 5
1 2 3 4 5 6 7
1 2 3 4 5 6 7 8 9

See you in the next one! ;)

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.