C Language is simple, kick and very popular programming language amongst programmers, C is the mother of all programming languages. So is the best to start learn programming. It was created by Dennis Ritchie in 1972 on the Bell Telephone Laboratories.

 

This language has a reduce number of keywords, so we need call libraries to expand the features of this language.

Very Popular libraries are:
  • stdio.h
  • math.h

 

Most of programmers use a cycle in the development of an application in c:
  1. The programmer write the code;
  2. The compiler compile the program and search for any kind of errors;
  3. The linker create the executable file;
  4. We run the program ( the executable file ).
Writing our first program:
#include <stdio.h>

int main(int argc, char** argv) {

    printf("Hello World");

    return (EXIT_SUCCESS);

}
Code Explained:
  • In line1 we call the librarie stdio.h, that contains the input output functions;
  • In line3 and line9 we have the opening and the closing of main function;
  • In line5 we call the function to print the message(string) ‘Hello World‘;
    1. printf = print + formatted
  • In line7 we  use ‘return (EXIT_SUCCESS);‘ to program close and retrieve success.

Note:

 Wich ".c" file only can have 1 main function

Variables and Data Types

In ‘C’ we need to declare the type of values that a variable will receive, before using it. Exist 4 types of variables:

  • char;
  • int;
  • float;
  • booleans.

Data Type ‘Char’

This type of data only can save/store on caracter.

Example:

//Only can store one letter/caracter
char letter = 'A';
//We use this method when user input a letter/caracter:
char letter;

Data Type ‘Int’

This type of data store integers.

Example:

// we can declare a integer when we knew the value that it will take
int integer = 7;
//we declare a integer when we don't know what value it will take
int integer;

Data Type ‘Float’

This data type store numbers with fractional part.

Note:

 In 'C' to use decimal plats we use . (dot) and not a , (comma).

Example:

//example of float
float pi = 3.14;
//Another example of how declare float data
float ray;

Data type ‘Boolean’

This type of data retrieve the values 0 (False) and 1 (True). In C Programming language, when write a condition this condition will retrieve 0 or 1, not true or false, unlike other programming languages


Leave a Reply

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