Tuesday 15 January 2019

Introduction

#Tutorial1#
The C programming language is a general purpose programming language, which relates closely to the way machines work. Understanding how computer memory works is an important aspect of the C programming language. Although C can be considered as "hard to learn", C is in fact a very simple language, with very powerful capabilities.

Our first program

Every C program uses libraries, which give the ability to execute necessary functions. For example, the most basic function called printf, which prints to the screen, is defined in the stdio.h header file.
To add the ability to run the printf command to our program, we must add the following include directive to our first line of the code:


#include <stdio.h> 
 
 The second part of the code is the actual code which we are going to write. The first code which will run will always reside
in the main function. 

int main() {
  ... our code goes here
}
The int keyword indicates that the function main will return an integer - a simple number. The number which will be returned by the function indicates whether the program that we wrote worked correctly. If we want to say that our code was run successfully, we will return the number 0. A number greater than 0 will mean that the program that we wrote failed. For this tutorial, we will return 0 to indicate that our program was successful:
return 0;


No comments:

Post a Comment

Note: only a member of this blog may post a comment.