FreeCprograms   Simple C Language Tutorial with free c programs

What is the use of C language in real life?

Many people don't know what is the use of C Language in real life. They are not aware why they are learning 'C'. Well this is for them. Let's see where C is used in real world.
Embedded devices use C. Microcontrollers like 8051,AVR and PIC uses basics of C language to program controllers.
C is used in the guts of most operating systems, especially for time-critical systems or to optimize graphical routines .
Real time operating systems use C. Parts of some other operating systems, such as the Linux kernel, are written in C. Some hardware drivers are written in C.
C can also be used for website programming using CGI as a "gateway" for information between the Web application, the server, and the browser.

How to install C Compiler?

After the download is complete extract the tc3 folder






How to make your first C program?

Here we will teach how you can start and make your first C program. C language is middle level language`.

To run a C program you need to have a C Compiler. Compiler is used to interpret our syntax (our program) into the machine code so that machine can understand our code.

 When we save the program an exe file along with Obj file is made. OBJ file is the machine code. You can easily download a Borland C compiler through internet.

After installing it you will find under TC folder - BGI | BIN | INCLUDE | LIB folders. Here we will only consider the BIN folder and the INCLUDE Folder for the moment. BIN folder contains TC.EXE.

 Execute this file then you will see something like we see below. All code written in c language is written in lower case letters. Now Lets make a program in C, here's what you need to do. Go to File menu and click new as shown below

By default the page opens as NONAME00.CPP. If you want to program in C++/CPP save page with .CPP extension.(Note: below is a c prog. its not a c++ prog.)

Rename the file and save it by your name with extension as 'c' e.g name.c as shown below. Now write this code as shown below in your TC. This c program on compilation will print your name.

For compiling this c program press ALT-F9.The output on compilation will print this as follows:

 

Free C Programs

C program to compute factorial

Call by value/ Call by Reference C program

Switch case c program

Command line arguments

Function call/Function Definition/Function Declaration

Passing a pointer to an array to a function C program

Pointers in C - C program

Linked Lists in C - C program

Recursion in C

What is an embedded system ?

An embedded system is a computer system designed to perform one or a few dedicated functions often with real-time computing.



C Programming and Embedded systems

The C programming language is perhaps the most popular programming language for programming embedded systems. C continues to be a very popular language for micro-controller developers/programmers due to the code efficiency and reduced overhead and development time. C offers low-level control and is considered more readable than assembly language which is a little difficult to understand. Assembly language requires more code writing, whereas C is easy to understand and requires less coding. Plus, using C increases portability, since C code can be compiled for different types of processors. We can program microcontrollers using 8051, AVR or PIC.

We can develop our programs as per our electronic hardware using 8051 micro controller. For example we can blink led, increment decrement counters, token displays etc.

C VS C++

The main difference between C & C++ is the OOPS (Object Oriented Programming) concept in C++.

This makes C++ much more efficient than C Language. C is procedure oriented language and c++ is object oriented language. But basically it depends on the project to project which language to choose from C or C++.

C language's syntax is very easy as compared to C++. Another Difference is that C uses Top Down approach and focuses on procedures.

In it Data moves as such whereas in C++ uses the bottom up approach and focuses basically on data . There is Data Hiding what we call as data abstraction.

Dynamic memory allocation in C is by calloc() and in C++ by malloc() by new and delete respectively. In C we only able to declare the variable in global declaration part, but in C++ it is possible to declare a variable in anywhere in the program.

This is a big advantage of C++ over C because it saves our time while coding. Function prototyping is optional in c whereas it is compulsion in c++.

Sample Syntax for C & C++

C++: -
cout << "Enter two integers";
cin >> v1 >> v2;

C: -
printf("Enter two integers");
scanf("%i %i", &v1, &v2);

In C, we cannot use template and template class. C source code file name should be *.c and *.h for implement file and header file.

Class is not supported in C, so you should convert all of class definition in C++ to structures and functions in C. C++ supports inheritance, polymorphism & encapsulation & C doesn't.


Access specifier in C is public, whereas in C++ it is private. C++ has more keywords than C.

Developers:

C: Dennis Ritche in 1972.
C++: Bjrane Stroustrup in 1980s


C++ VS JAVA

On the Other hand, Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform.

It has no preprocessor.

If you want to use classes in another library, we have to import with name of the library.

There are no preprocessor-like macros.

Java uses packages in place of namespaces.

There are no Java pointers like in the C and C++.

There are no destructors in Java. Java has constructors, similar to constructors in C++.

Java has method overloading that works similar to C++ function overloading.

Java does not support default arguments.

There’s no goto in Java. Java has no templates.

Inheritance in Java is similar as in C++, but the syntax is different.


C language is used to clear our basic concepts so as to learn C++ and Java.

C++ Language =Procedural language with Object Oriented extension.

Java Language=It is PURE OBJECT ORIENTED LANGUAGE.

OBJECT ORIENTED LANGUAGE

Objective of this type of approach is to remove the flaws encountered in procedural approach that is in C++.

It treats data as a critical element and does not allows it to move freely around the system. It ties data more closely to the functions that operate on it and prevents it from unintentional modification by other functions or methods. It allows us to decompose a problem in to number entities called objects. Emphasis is on data rather than procedure.

green ones are methods or functions where as brown one is data.

OBJECT=DATA +METHODS

Data is hidden and can't be accessed by external functions.Follows bottom up approach.Objects can communicate with each other through methods. New data and methods can be added whenever necessary.

CLASSES: Collection of objects of similar type.

Data Encapsulation and Data abstraction:

Wrapping up of data and methods into class is encapsulation. Classes uses concept of abstraction which includes hiding of data and showing only essential features.

INHERITANCE: Properties by which objects of one class acquire the properties of objects of another class.

POLYMORPHISM: Ability to take more than one form. e.g Shape can be circle, box, triangle.

Benefits of OOP: Through inheritance we can eliminate redundant code. Saves development time and higher productivity.

Easy to partition the work. Software Complexity can be easily managed. Easy upgradation from small to large systems.

Applications of OOPs:


Real Time systems

Simulation and Modelling

Object oriented databases

Hyper text, Hyper media

Artificial intelligence

Parallel programming

Decision support and office automation systems

CIM,CAD Systems.

Join me on Facebook www.facebook.com/itsvijay

Email: vijayendra2@gmail.com

Website: www.vijayendrasingh.com 

 

Disclaimer    Privacy Policy    copyright freecprograms.com