Introduction to C Language and Programming (Part I)

C language is a very good start to learn programming languages, C language is a very easy to learn and handle, and it is not a scripting language, when you are learning C language, you must have a compiler, the executable files are created by compiler using your codes, to do that you have to have a compiler.

If you are a Windows user, you can use C Free and it’s very easy to handle.
If you are a Linux user, you can use GCC.
If you are a Mac OS user, you can use XCode.

or use Eclipse
You can go and download them, the first step is you should have the compiler.

Now we can learn the C.

When we are considering about the C language, there are a lot of Functions,
In a Function there are some commands to do some task.
There is a function call as “Main” in C, Main function is always executed first when runs the program.
Main is the anchor to link and call to other functions. Here is the first “Hello World” Program to test as a beginner, copy and try it with your compiler.

#include <stdio.h>
int main()
{   
printf( “Hello World. \n”);
}

#include
Compiler is leaded to get the code from header, and put to your program which you have written and then create the executable file. The header is <Stdio.h>, you can use header file to get access a lot of functions.
int main()
Compiler is informed about the main function by this code.
printf
“Printf” is a function that can display any output on a screen, Compiler is learned that line which you want to print by quotes.
“\n” 
it is using to get new line, try to get another result without it, and you’ll learn. And try below program also

#include <stdio.h>
int main()
{   
printf( “Hello hsemin\n”);   
getchar();   
return 0;
}

Did you run the above code, you had better run and see the results, compare with first program output, and you will be able to find some different changes. You can see above code has a new function, that is:

getchar();
And a new statement is called as: return 0;
I’ll explain what’s going with those.

getchar();
By using this function we can wait until user press the Enter key, then you won’t see the line “Press any key to continue


return 0; By using this return statement can return value from “main” to the operating system. It will inform to the OS whether our program was succeeded or not. Returns value of 0 means success.


Compile above basic programs and get the results.

Leave a Comment

Your email address will not be published. Required fields are marked *