Friday, June 12, 2015

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.

  6 comments:

  1. This technical post helps me to improve my skills set, thanks for this wonder article I expect your upcoming blog, so keep sharing..
    Regards,
    ccna training in Chennai

    ReplyDelete
  2. Nice..Its informative...You have clearly explained about the concept..Its very useful for me to understand..Keep on sharing..
    CCNA training in chennai

    ReplyDelete
  3. Well Said, you have furnished the right information that will be useful to anyone at all time. Thanks for sharing your Ideas.
    SAS Training in Chennai | SAS Course in Chennai

    ReplyDelete
  4. Very interesting content which helps me to get the indepth knowledge about the technology. To know more detils about the course visit this website.
    Digital marketing course in Chennai | Digital marketing training in Chennai

    ReplyDelete
  5. Updating with the latest technology and implementing it is the only way to survive in our niche. Thanks for making me this article.
    SAS Training in Chennai | SAS Training Institute in Chennai

    ReplyDelete

Facebook Fan Page

Popular Posts

Powered by Blogger.