C Language
- C is a professional programmer's language.
- It was designed to get in one's way as little as possible.
- Kernighan and Ritchie wrote the original language definition in their book.
- The C programming Language, as part of their research at AT&t, Unix and C++ emerged from the same labs.
- Some languages are forgiving.
- The programmer needs only a basic sense of how things work.
- Errors in the code are flagged by the compile-time or run-time system, and the programmer can muddle through and eventually fix things up to work correctly. The C language is not like that.
- C is "simple" in that the number of components in the language is small-- If two language features accomplish more-or-less the same thing.
- C will include only one.C's syntax is terse and the language does not restrict what is "allowed" --the programmer can pretty much do whatever they want.
- C's type system and errer checks exist only at compile-time.
- The compiled code runs in a stripped doe=wn run-time model with no safety checks for bad type casts, bad array indices, or bad pointers.
- There is no garbage collector to manage memory. Instead the programmer manages heap memory manually. All this makes C fast but fragile.
A C program basically has the following
form:
The following program is written in the C
programming language. Open a text file hello.c using
vi editor and put the following lines inside that file.
#include
int main()
{
/* My first program */
printf("Hello, World! \n");
return 0;
}
Preprocessor Commands: These commands
tells the compiler to do preprocessing before doing actual compilation.
Like #include
Functions: are main building blocks
of any C Program. Every C Program will have one or more functions and there
is one mandatory function which is called main() function.
This function is prefixed with keyword int which means this
function returns an integer value when it exits. This integer value is retured
using return statement.
The C Programming language provides a set
of built-in functions. In the above example printf()is a C
built-in function which is used to print anything on the screen. Check Built in function section for more detail.
Variables: are used to hold
numbers, strings and complex data for manipulation. You will learn in detail
about variables in C Variable Types.
Statements & Expressions : Expressions combine
variables and constants to create new values. Statements are expressions,
assignments, function calls, or control flow statements which make up C
programs.
Comments: are used to give additional useful
information inside a C Program. All the comments will be put inside /*...*/
as given in the example above. A comment can span through multiple lines.
|
No comments:
Post a Comment