Chapter 1. What Is C?

Contributed By : Shehrevar Davierwala

  1. What Is C?

C is a programming language that allows a software engineer to efficiently communicate with a computer.
C is a highly flexible and adaptable language. Since its creation in 1970, it’s been used for a wide variety of programs including firmware for micro -controllers, operating systems, applications, and graphics programming.
C is one of the most most widely used languages in the read more

Chapter 2 How to install C? Environment Setup

Contributed By: Shehrevar Davierwala

You really do not need to set up your own environment to start learning C programming language. Try following example using our online compiler option available at http://www.compileonline.com/.

Local Environment Setup:

If you want to set up your environment for C programming language, you need the following two software tools available on your computer, (a) Text Editor and (b) The C Compiler.

What is a text editor?

This will be used to type your program. read more

Chapter 3 My first C Program

Contributed By: Shehrevar Davierwala

A C program, whatever its size, consists of functions and variables. A function contains
statements that specify the computing operations to be done, and variables store values
used during the computation.

Below is the simple program in C

1 /* First C program: Hello World */
2 #include <stdio.h>
3
4 int main(void)
5 {
6 printf(“Hello World!\n”);
7 }

(Please avoid read more

Chapter 4. How to compile & execute C program?

Contributed by : Shehrevar Davierwala

( Note below lines of code are with respect to gnu )

The Compiler
A C program is made by running a compiler which takes the typed source
program and converts it into an object file that the computer can execute. A
compiler usually operates in two or more phases.

  •  Phase 1 scans a source program, perhaps generating an intermediate
    code (quadruples or pcode) which helps to simplify the grammar of the
    language for subsequent processing. It then converts the intermediate
    code into a file of object code (though this is usually not executable
    yet). A separate object file is built for each separate source file. In the
    GNU C compiler, these two stages are run with the command gcc -c;
    the output is one or more .o files.
  • Phase 2 is a Linker. This program appends standard library code to
    the object file so that the code is complete and can “stand alone”. A C
    compiler linker suffers the slightly arduous task of linking together all
    the functions in the C program. Even at this stage, the compiler can
    fail, if it finds that it has a reference to a function which does not exist.
    With the GNU C compiler this stage is activated by the command gcc
    -o or ld.

On GNU systems, this results in the creation of an executable program
with the default name a.out. To tell the compiler what you would like the
executable program to be called, use the -o read more

Summary for Chapter 1 to 4

Contributed By: Shehrevar Davierwala

    1. Structure of C program
      #include <stdio.h>
      /* Include files for input/output functions*/
      #define const_namevalue
      /* constant declaration if required */
      main() /* Main function */
      { /* each declarations and statements are separated by semi colon */
      declarations
      /* variables; arrays; records;
      function declarations etc */
      statements
      }
read more

Chapter 5. Basic Syntax in C

Contributed By: Shehrevar Davierwala

1. What is C Tokens ? or Tokens?

A C program consists of various tokens and a token is either a keyword, an identifier, a constant, a string literal, or a symbol. For example, the following C statement consists of five tokens:
printf(“Hello, World! \n”);
The individual tokens are:
printf
(
“Hello, World! \n”
)
;

2. Why should we use semicolons ?

In a C program, the semicolon is a statement terminator. That is, each individual statement read more

Chapter 6. Basics of Program Writing in Unix/Linux

Contributed By: Shehrevar Davierwala

The first and most important thing of all, at least for writers today, is
to strip language clean, to lay it bare down to the bone.
—Ernest Hemingway

1. How to start writing program in C using Linux based compiler (gcc/GNU)

Step 1. You can more easily manage things if you create a separate directory for each
program that you’re working on. In this case, we’ll create a directory called hello to
hold our hello program.
On UNIX/Linux read more