c programming language

How to learn C Programming language

One of the most popular languages ​​is the C language.  It is use for code the program.  C language is a high-level programming language.  Here we will learn the basic concepts.  There is currently a lot of software available for this purpose.  Fedora terminal, Visual Studios, Code Blocks, Ubuntu are just a few examples.  We are using a Fedora operating system.

 There are three main functions of the C program. There are source code, translator and object code (machine language code). The main work of these three is to translate the code we entered into a computer language. Here we can identify several translators. There are Assemblers (convert assembly language to machine language), Compiler (convert high level language to machine language) and interpreter (execute high level language program by line).

Create a file

First, the terminal is turned on, and the file creates a file.

                        Vi filename.c

In this case, the extension must be placed in .c.

Start the program

Start the program

Then open the file and add the program. The program included is the source code. This program is started,

#include <stdio.h>

 After that start the main program.

   int main (void) {}

Write the program in this main function.

 Ex:

        #include <stdio.h>

int main (void) {

           }

 Here we add the return 0 in the main function.

That means the program will end there.

  include <stdio.h>

                int main (void){

                  return 0; }

“Printf” is used to print sentences in this program.

                     include <stdio.h>

                      int main (void) {

                       Printf (“hello world”);

                      return 0; }

variables

You can also use the variables here. Where a value is in memory where a value can be stored for use by the program, variables must be declared before they can be given a value.  When declaring a variable, its name and data type should be specified. Each variable has a name, type and a value. The declaration allocates the storage location of the appropriate size and associates the name and data type with that location.

 Integers = int (% d),

 Real numbers = float (% f), double (% d),

 Characters = char (% c).

Variable does not begin with a digit.

 May not contain embedded blank space.

 May not be a reserved word. (int, return, if, while, for).

 For example:

                         01].

                                           include <stdio.h>

                                           int main (void) {

                                           int no;

                                           no = 5;

                                           Printf ( “% d”, no);

                                           return 0; }

                       02].

                                           include <stdio.h>

                                           int main (void) {

                                           float no;

                                           no = 5.3500;

                                           Printf (“% f”, no);

                                           return 0; }

 03].

                                           include <stdio.h>

                                           int main (void) {

                                           double no;

                                           no = 5.35;

                                           Printf (“% lf”, no);

                                           return 0; }

c-programming-language
c programming

calculations

  In addition, it can include addition, multiplication, and division.

 For example:

                         01].

                                           include <stdio.h>

                                           int main (void) {

                                           int no1, no2, no3;

                                           no1 = 5;

                                           no2 = 3;

                                           no3 = no1 + no2;

                                           Printf (“% d”, no3);

                                           return 0; }

                       02].

                                           include <stdio.h>

                                           int main (void) {

                                           int no1, no2;

                                           no1 = 5;

                                           no2 = 3;

                                           Printf (“% d”, no1 + no2);

                                           return 0; }

comments

 It is important to comment here.

 Here is the single line comment and many line comment. Only line comment ‘//’ and multiple line comment ‘/ ** /’.

 For example:

                            01].

                                           // c program start

                                           include <stdio.h>

                                           // start the main function

                                           int main (void) {

                                           // variables

                                           int no1, no2;

                                           no1 = 5;

                                           no2 = 3;

                                           // sum veriables

                                           no3 = no1 + no2;

                                           // print the output

                                           Printf (“% d”, no3);

                                           // return function

                                           return 0; }

Save the program

This way, the coding program needs to be saved before executing it. For this, press the save button and press ‘:’ after press w and q and ‘!’ .

  (: wq!) press enter button.

After you can see the terminal, then we have to enter gcc file name.c -o file save the name.

  gcc nike.c -o nik

 nike.c = file name and nik = file save name

If the c program is correct, it can execute correctly.

  ./save name

  (./Nik)

 It shows very simple c program theories. Read more

Thank you.

Our other articles = Click here