Understanding About C language

C is a General Purpose Computer Programming Language.

C was originally developed by Dennis Ritchie between 1969 and 1973 at Bell
Labs, and used to re-implement the Unix operating system.

The C Compiler,unix operating System and all essentially unix Application 
programs have been written in C.

Now a Days , C is Widely used by Professionals .
And it also is a basic language of all others language .

Now a Days,in Colleges , C language is the must topics for every students of
Engineering colleges whether it is in mechanical branch or in Electronics
branch or in Computer Science branch Etc.

Reasons for widely used C language :
1. Easy to learn.
2. It Produce Efficient Programs. 
3. Basic Language
4. Structred language
5. Most important, It can handle Low level Activities.
6. It can compiled on a variety of Computer Platforms.

Note :
Most popular Linux OS and RDBMS MySQL have been written in C.


What is the Use of C and Why all professional and MNC company Prefer C For 
developing Softwares ?

Initially,C was used for System Development work,particularly the programs
that make Operating System.

C language code runs as fast as the code written in assembly Language.

Use of C
1. In Operating Systems such as UNIX,Linux
2. In language Compilers
3. In Assemblers
4. In Text Editors
5. Print Spoolers
6. Network Drivers
7. Modern Programs
8. Databases such as Mysql
9. Language Interpreters
10. Utilities 
11. Calculators


Understanding Of C

C language can vary from  a single line to million of lines . and it should be
written in more than one text files having extension ".c" for example
"HelloWorld.c"

C can be used in any Editors like Notepad,Notepad ++ ,Vi ,Vim etc.

First Example and Basic Example oF C Language

#include <stdio.h>

int main() {
   /* my first program in C */   /* This is a comment Line*/
   printf("Hello World! \n");
   
   return 0;
}

Save it as Helloworld.c in any editor.

The Files create with the editor are called as source file and they contain

the program source code having extension in the file name ".c".


A c Program Basically consist of Following Parts :- 
1. Preprocessor Commands
2. Functions 
3. Variables
4. Statements & Expressions
5. Comments

Let us look at a simple code that would print the words "Hello World" −

#include <stdio.h>

int main() {
   /* my first program in C */
   printf("Hello, World! \n");
   
   return 0;
}

Let us take a look at the various parts of the above program −
1. The first line of the program #include <stdio.h> is a preprocessor command,
which tells a C compiler to include stdio.h file before going to actual
compilation.

2. The next line int main() is the main function where the program execution
begins.

3. The next line /*...*/ will be ignored by the compiler and it has been put
to add additional comments in the program. So such lines are called comments
in the program.it is for information about the line to the programmer.

4. printf("...") is another function available in C which displayed the result
on the screen which is written inside the close bracket ("...").

5. The next line return 0; terminates the main() function and returns the
value 0. u have to remember about this line ,you have to put this line
compulsory in every c programm. I will explain later about this line .


In a C  Program , Semicolon is a Statement terminator.
That means each individual statement must be ended with a semicolon.
For example :
printf("Hello world");


Comments
Comments are like helping text in your C program and they are ignored by the compiler. they start with /* and also terminate with the characters */ as shown below

:
/* printf helps to display

the message*/

Keywords in C language which are reserved and may not used as constant,variables,and other identifiers names.


enum ,int, string, typedef, define, auto, else, if, for, long, switch, break, register, case, extern, union, return, char, float, short, unsigned, const, signed, void, continue, goto, sizeof, volatile, default, static, while, do, struct, _packed, double

Data Types

Data Types in C refer to an extensive system used for declaring variables or functions of Different types.The type of variables determines how much space it occupies in storage.
Various Data Types are : 
1. Integer Types
2. Floating-point Types
3. Enumerated Types
4. Void Types
5. Pointer Types
6. Array Types
7. Structure Types
8. Union Types
9. Function Types


Interger Types

Standard Integer Types with their Storage sizes and value ranges are :-

TypeStorage sizeValue range
char1 byte-128 to 127 or 0 to 255
unsigned char1 byte0 to 255
signed char1 byte-128 to 127
int2 or 4 bytes-32,768 to 32,767 or -2,147,483,648 to 2,147,483,647
unsigned int2 or 4 bytes0 to 65,535 or 0 to 4,294,967,295
short2 bytes-32,768 to 32,767
unsigned short2 bytes0 to 65,535
long4 bytes-2,147,483,648 to 2,147,483,647
unsigned long4 bytes0 to 4,294,967,295

To get the exact size of a type or a variable on a particular platform, you can use the sizeof operator. The expressions sizeof(type) yields the storage size of the object or type in bytes. Given below is an example to get the size of int type on any machine −

#include <stdio.h>
#include <limits.h>

int main() {

   printf("Storage size for int : %d \n", sizeof(int));
   
   return 0; }

When you compile and execute the above program, it produces the following result on Linux −


Storage size for int : 4


Comments